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).
- 🧠 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
- Cloudflare account (free tier works!)
- Mem.ai account and API key
- Wrangler CLI installed
- Node.js 18+ and npm
# 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.shThe setup script will:
- Create KV namespaces (for OAuth mode)
- Generate
wrangler.tomlconfiguration - Configure secrets (API keys)
- Guide you through OAuth setup (if selected)
Secure access with GitHub OAuth authentication.
# During setup, choose option 1
./setup.sh
# Deploy to Cloudflare
npm run deployOAuth Setup Requirements:
- Create a GitHub OAuth App at https://github.com/settings/developers
- Set callback URL to:
https://mem-mcp-server.<your-subdomain>.workers.dev/github/callback - Configure Client ID and Secret during setup
No OAuth - direct API key authentication.
# During setup, choose option 2
./setup.sh
# Deploy to Cloudflare
npm run deploy# Start local development server
npm run dev
# Access at http://localhost:8787Save and automatically process any content type with AI-powered organization.
Parameters:
input(required): Content to save (text, HTML, markdown)instructions(optional): Processing instructionscontext(optional): Additional contexttimestamp(optional): ISO 8601 timestamp
Example:
{
"input": "Meeting notes: Discussed Q1 roadmap...",
"instructions": "Extract action items",
"context": "Product Planning"
}Create a markdown-formatted note with explicit organization.
Parameters:
content(required): Markdown contentcollection_ids(optional): UUIDs of collectionscollection_titles(optional): Collection titles
Retrieve full note content and metadata.
Parameters:
note_id(required): UUID of the note
Permanently delete a note.
Parameters:
note_id(required): UUID of the note
Create a collection for organizing related notes.
Parameters:
title(required): Collection titledescription(optional): Markdown description
Delete a collection (notes remain, just unassociated).
Parameters:
collection_id(required): UUID of the collection
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_SECRETGenerated 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"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)
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
| 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 |
| Endpoint | Description |
|---|---|
/ |
Server information |
/sse |
SSE endpoint (no auth) |
/health |
Health check |
Add to claude_desktop_config.json:
{
"mcpServers": {
"mem": {
"url": "https://mem-mcp-server.<your-subdomain>.workers.dev/sse"
}
}
}Claude will handle OAuth flow automatically.
{
"mcpServers": {
"mem": {
"url": "https://mem-mcp-server.<your-subdomain>.workers.dev/sse"
}
}
}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!
# Test locally
npm run dev
# Check health endpoint
curl http://localhost:8787/health
# Test root endpoint
curl http://localhost:8787/View logs and analytics in Cloudflare Dashboard:
# View live logs
wrangler tail
# Check deployment status
wrangler deployments list- Check that
MEM_API_KEYis set correctly - Verify API key is valid at https://mem.ai
- Run migrations:
wrangler migrations apply - Redeploy:
npm run deploy
- Verify GitHub OAuth app callback URL matches your worker URL
- Check
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRETare set
- Run
setup.shagain to recreate namespaces - Manually create via Cloudflare Dashboard
Contributions welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Mem.ai - Intelligent memory platform
- Mem.ai API Docs
- Model Context Protocol
- Cloudflare Workers
- Python Version - FastMCP Python implementation
- mcp-limitless - Limitless AI MCP server (template for this project)
- mcp-mem.ai - Python FastMCP version
- Built with Cloudflare Workers
- OAuth flow based on mcp-limitless
- Powered by Mem.ai
Built with ❤️ using Cloudflare Workers and TypeScript