BurtTheCoder/mcp-mem.ai-cfw
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).
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).
โจ 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
- Cloudflare account (free tier works!)
- Mem.ai account and API key
- Wrangler CLI installed
- Node.js 18+ and npm
๐ 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:
- Create KV namespaces (for OAuth mode)
- Generate
wrangler.toml
configuration - Configure secrets (API keys)
- 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:
- 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
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 instructionscontext
(optional): Additional contexttimestamp
(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 contentcollection_ids
(optional): UUIDs of collectionscollection_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 titledescription
(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
andGITHUB_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.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
๐ License
This project is licensed under the MIT License - see the file for details.
๐ Links
- Mem.ai - Intelligent memory platform
- Mem.ai API Docs
- Model Context Protocol
- Cloudflare Workers
- Python Version - FastMCP Python implementation
๐ก Related Projects
- mcp-limitless - Limitless AI MCP server (template for this project)
- mcp-mem.ai - Python FastMCP version
๐ Acknowledgments
- Built with Cloudflare Workers
- OAuth flow based on mcp-limitless
- Powered by Mem.ai
Built with โค๏ธ using Cloudflare Workers and TypeScript