mcp-mem.ai-cfw

BurtTheCoder/mcp-mem.ai-cfw

3.3

If you are the rightful owner of mcp-mem.ai-cfw and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Mem.ai MCP Server is a Cloudflare Worker that provides AI assistants with intelligent access to Mem.ai's knowledge management platform via the Model Context Protocol (MCP).

Tools
6
Resources
0
Prompts
0

Mem.ai MCP Server - Cloudflare Worker

A production-ready Cloudflare Worker that provides AI assistants with intelligent access to Mem.ai's knowledge management platform via the Model Context Protocol (MCP).

Cloudflare Workers TypeScript License: MIT

โœจ Features

  • ๐Ÿง  Intelligent Memory: Save and process content with Mem It's AI-powered organization
  • ๐Ÿ“ Note Management: Create, read, and delete structured markdown notes
  • ๐Ÿ“ Collections: Organize notes into searchable collections
  • ๐Ÿ”’ OAuth Protected: GitHub OAuth authentication (optional)
  • โšก Edge Deployment: Low-latency access via Cloudflare's global network
  • ๐Ÿ†“ Free Tier: Runs on Cloudflare's generous free tier
  • ๐ŸŽฏ 6 MCP Tools: Complete Mem.ai API coverage

๐Ÿ“‹ Prerequisites

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/BurtTheCoder/mcp-mem.ai-cfw.git
cd mcp-mem.ai-cfw

# Install dependencies
npm install

# Run automated setup
./setup.sh

The setup script will:

  1. Create KV namespaces (for OAuth mode)
  2. Generate wrangler.toml configuration
  3. Configure secrets (API keys)
  4. Guide you through OAuth setup (if selected)

Deployment Modes

Option 1: OAuth-Protected (Recommended for Production)

Secure access with GitHub OAuth authentication.

# During setup, choose option 1
./setup.sh

# Deploy to Cloudflare
npm run deploy

OAuth Setup Requirements:

  1. Create a GitHub OAuth App at https://github.com/settings/developers
  2. Set callback URL to: https://mem-mcp-server.<your-subdomain>.workers.dev/github/callback
  3. Configure Client ID and Secret during setup
Option 2: Simple Mode (Development)

No OAuth - direct API key authentication.

# During setup, choose option 2
./setup.sh

# Deploy to Cloudflare
npm run deploy

Local Development

# Start local development server
npm run dev

# Access at http://localhost:8787

๐Ÿ› ๏ธ Available MCP Tools

1. mem_it - Intelligent Content Processing

Save and automatically process any content type with AI-powered organization.

Parameters:

  • input (required): Content to save (text, HTML, markdown)
  • instructions (optional): Processing instructions
  • context (optional): Additional context
  • timestamp (optional): ISO 8601 timestamp

Example:

{
  "input": "Meeting notes: Discussed Q1 roadmap...",
  "instructions": "Extract action items",
  "context": "Product Planning"
}

2. create_note - Create Structured Note

Create a markdown-formatted note with explicit organization.

Parameters:

  • content (required): Markdown content
  • collection_ids (optional): UUIDs of collections
  • collection_titles (optional): Collection titles

3. read_note - Read Note by ID

Retrieve full note content and metadata.

Parameters:

  • note_id (required): UUID of the note

4. delete_note - Delete Note

Permanently delete a note.

Parameters:

  • note_id (required): UUID of the note

5. create_collection - Create Collection

Create a collection for organizing related notes.

Parameters:

  • title (required): Collection title
  • description (optional): Markdown description

6. delete_collection - Delete Collection

Delete a collection (notes remain, just unassociated).

Parameters:

  • collection_id (required): UUID of the collection

โš™๏ธ Configuration

Environment Variables (Secrets)

Set via wrangler secret put:

# Required
wrangler secret put MEM_API_KEY

# Optional (for OAuth mode)
wrangler secret put GITHUB_CLIENT_ID
wrangler secret put GITHUB_CLIENT_SECRET

wrangler.toml

Generated by setup.sh. Manual configuration:

name = "mem-mcp-server"
main = "src/github-oauth-index.ts"  # or src/simple-index.ts
compatibility_date = "2024-09-23"
compatibility_flags = ["nodejs_compat"]

[[durable_objects.bindings]]
name = "MCP_AGENT"
class_name = "MemMCPAgent"

[[migrations]]
tag = "v1"
new_sqlite_classes = ["MemMCPAgent"]

# For OAuth mode only:
[[kv_namespaces]]
binding = "OAUTH_KV"
id = "your_kv_namespace_id"
preview_id = "your_preview_kv_id"

๐Ÿ—๏ธ Architecture

src/
โ”œโ”€โ”€ types.ts               # TypeScript interfaces & Zod schemas
โ”œโ”€โ”€ mem-client.ts          # Mem.ai API client
โ”œโ”€โ”€ mcp-agent.ts           # Durable Object with 6 MCP tools
โ”œโ”€โ”€ github-oauth-index.ts  # OAuth-protected worker
โ””โ”€โ”€ simple-index.ts        # Simple worker (no OAuth)

Key Components

1. Durable Object (mcp-agent.ts)

  • Stateful MCP server instance
  • Handles all 6 Mem.ai tools
  • Uses SQLite for persistence

2. API Client (mem-client.ts)

  • TypeScript wrapper for Mem.ai API
  • Error handling and validation
  • Type-safe with Zod schemas

3. OAuth Handler (github-oauth-index.ts)

  • GitHub OAuth flow
  • PKCE support
  • Token management with KV storage

4. Simple Handler (simple-index.ts)

  • Direct SSE endpoint
  • No authentication overhead
  • Perfect for development

๐Ÿ“š API Endpoints

OAuth Mode

EndpointDescription
/Server information
/authorizeOAuth authorization
/tokenToken exchange
/github/callbackOAuth callback
/sseSSE endpoint (authenticated)
/.well-known/oauth-authorization-serverOAuth discovery

Simple Mode

EndpointDescription
/Server information
/sseSSE endpoint (no auth)
/healthHealth check

๐Ÿ”ง Claude Desktop Integration

OAuth Mode

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "mem": {
      "url": "https://mem-mcp-server.<your-subdomain>.workers.dev/sse"
    }
  }
}

Claude will handle OAuth flow automatically.

Simple Mode

{
  "mcpServers": {
    "mem": {
      "url": "https://mem-mcp-server.<your-subdomain>.workers.dev/sse"
    }
  }
}

๐Ÿ’ฐ Cloudflare Free Tier

This worker runs comfortably on Cloudflare's free tier:

  • โœ… 100,000 requests/day
  • โœ… 10ms CPU time per request
  • โœ… Unlimited Durable Objects
  • โœ… 1GB KV storage

Perfect for personal use and small teams!

๐Ÿงช Testing

# Test locally
npm run dev

# Check health endpoint
curl http://localhost:8787/health

# Test root endpoint
curl http://localhost:8787/

๐Ÿ“Š Monitoring

View logs and analytics in Cloudflare Dashboard:

# View live logs
wrangler tail

# Check deployment status
wrangler deployments list

๐Ÿ› Troubleshooting

"Authentication failed"

  • Check that MEM_API_KEY is set correctly
  • Verify API key is valid at https://mem.ai

"Durable Object not found"

  • Run migrations: wrangler migrations apply
  • Redeploy: npm run deploy

OAuth callback fails

  • Verify GitHub OAuth app callback URL matches your worker URL
  • Check GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET are set

"KV namespace not found"

  • Run setup.sh again to recreate namespaces
  • Manually create via Cloudflare Dashboard

๐Ÿค Contributing

Contributions welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the file for details.

๐Ÿ”— Links

๐Ÿ’ก Related Projects

๐Ÿ™ Acknowledgments


Built with โค๏ธ using Cloudflare Workers and TypeScript