MCP Servers

模型上下文协议服务器、框架、SDK 和模板的综合目录。

Cloudflare Worker MCP server for Mem.ai - Edge-deployed intelligent memory platform with OAuth protection

创建于 10/2/2025
更新于 2 months ago
Repository documentation and setup instructions

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

| Endpoint | Description | |----------|-------------| | / | Server information | | /authorize | OAuth authorization | | /token | Token exchange | | /github/callback | OAuth callback | | /sse | SSE endpoint (authenticated) | | /.well-known/oauth-authorization-server | OAuth discovery |

Simple Mode

| Endpoint | Description | |----------|-------------| | / | Server information | | /sse | SSE endpoint (no auth) | | /health | Health 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 LICENSE file for details.

🔗 Links

💡 Related Projects

🙏 Acknowledgments


Built with ❤️ using Cloudflare Workers and TypeScript

快速设置
此服务器的安装指南

安装包 (如果需要)

npx @modelcontextprotocol/server-mcp-mem.ai-cfw

Cursor 配置 (mcp.json)

{ "mcpServers": { "burtthecoder-mcp-mem-ai-cfw": { "command": "npx", "args": [ "burtthecoder-mcp-mem-ai-cfw" ] } } }