How to Add Persistent Memory to Claude.ai (5-Minute Setup)
Give Claude a brain that persists across sessions. Self-hosted, open source, works directly in your browser — no desktop app required.
The Problem
Claude is powerful, but it doesn't remember context between sessions. Every conversation starts from scratch.
Sure, ChatGPT has memory. Gemini has memory. Claude Desktop has extensions.
But what if you:
- Use claude.ai in the browser (no desktop app)
- Want to own your data (no third-party cloud)
- Need enterprise security (OAuth 2.0, HTTPS, CORS)
- Require self-hosted infrastructure (compliance, privacy)
That's where mcp-memory-service comes in.
What is mcp-memory-service?
An open-source persistent memory layer for Claude that implements the Model Context Protocol (MCP). Unlike other solutions, it supports Remote MCP — meaning it works directly in claude.ai browser without requiring Claude Desktop.
What Makes It Different?
| Feature | mcp-memory-service | mem0 | Others |
|---|---|---|---|
| Works in claude.ai browser | Yes | No | No |
| Knowledge graph | Typed edges | No | No |
| Auto-consolidation | Decay + compression | No | No |
| Self-hosted | Yes | Yes | Varies |
| OAuth 2.0 + DCR | Yes | ? | No |
| Hybrid search (BM25 + vector) | Yes | No | No |
| License | Apache 2.0 | MIT | Varies |
5-Minute Setup Tutorial
Let's get mcp-memory-service running with Remote MCP for claude.ai.
Prerequisites
- Python 3.10+
- A machine that can run 24/7 (VPS, home server, or your laptop for testing)
- 5 minutes of your time
No domain name required — we'll use Cloudflare Tunnel for free HTTPS.
Install mcp-memory-service
# Clone the repository
git clone https://github.com/doobidoo/mcp-memory-service.git
cd mcp-memory-service
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or: venv\Scripts\activate # Windows
# Install dependencies
pip install -e .
Configure for Remote MCP
Create a .env file:
# Remote MCP Configuration
MCP_STREAMABLE_HTTP_MODE=1
MCP_SSE_HOST=0.0.0.0
MCP_SSE_PORT=8765
# OAuth Configuration
MCP_OAUTH_ENABLED=true
MCP_OAUTH_STORAGE_BACKEND=sqlite
MCP_OAUTH_SQLITE_PATH=./data/oauth.db
# Memory Configuration (optional)
MCP_MEMORY_CONSOLIDATION_ENABLED=true
MCP_MEMORY_DECAY_ENABLED=true
What these settings do:
STREAMABLE_HTTP_MODE=1— Enables Remote MCP (the future, SSE is deprecated)SSE_HOST=0.0.0.0— Allows external connections (not just localhost)OAUTH_ENABLED=true— Secure authentication for claude.ai
Start the Server
python -m mcp_memory_service.server
You should see:
[INFO] MCP Memory Service starting...
[INFO] Streamable HTTP transport enabled
[INFO] OAuth 2.0 server initialized
[INFO] Server running on http://0.0.0.0:8765
[INFO] MCP endpoint: http://0.0.0.0:8765/mcp
Expose with Cloudflare Tunnel
In a new terminal:
# macOS
brew install cloudflared
# Linux
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared-linux-amd64.deb
# Start tunnel
cloudflared tunnel --url http://localhost:8765
You'll see:
Your quick Tunnel has been created! Visit it at:
https://random-name-1234.trycloudflare.com
Copy that URL — you'll need it next.
This is a temporary tunnel. For production, use a permanent Cloudflare Tunnel or your own domain with Let's Encrypt.
Connect to claude.ai
- Go to claude.ai
- Click your profile → Settings
- Navigate to Connectors
- Click Add Connector
- Paste your tunnel URL +
/mcp:https://random-name-1234.trycloudflare.com/mcp - Complete the OAuth flow → Done!
Claude now has persistent memory. All 12 memory tools are available in your conversations.
Test It Out
In a new Claude conversation:
You: "Store a memory: My favorite programming language is Rust"
Claude: "I've stored that memory."
--- close conversation, open new one ---
You: "What's my favorite programming language?"
Claude: "Your favorite programming language is Rust!"
It remembers!
How It Works
- You interact with Claude in the browser
- Claude detects memory tools from your connector
- When relevant, Claude calls
memory_store()ormemory_search() - Request goes to your server via HTTPS (OAuth token authenticates it)
- Memory is stored/retrieved from your local database
- Claude uses the context in its response
All communication is encrypted (HTTPS), authenticated (OAuth 2.0), and private (data never leaves your infrastructure).
The Knowledge Graph
Unlike simple key-value storage, mcp-memory-service builds a knowledge graph with typed edges:
Memory: "Favorite language is Rust"
↓ relates_to: programming
↓ preference_for: language
Memory: "Working on a web server"
↓ uses_technology: backend
↓ relates_to: architecture
This allows Claude to find related memories contextually, understand relationships between facts, and provide better answers by connecting the dots.
Auto-Consolidation
Over time, memories accumulate. mcp-memory-service automatically:
- Decays — Reduces importance of old, unused memories
- Compresses — Merges similar memories (e.g., 5 mentions of "likes Rust" → 1 consolidated memory)
- Prunes — Archives memories with zero relevance score
Production Deployment
Option 1: Permanent Cloudflare Tunnel
# Authenticate
cloudflared tunnel login
# Create tunnel
cloudflared tunnel create memory-service
# Route traffic
cloudflared tunnel route dns memory-service memory.yourdomain.com
# Run (use systemd/supervisor in production)
cloudflared tunnel run memory-service
Option 2: Your Own Domain + Let's Encrypt
# Get certificate
certbot certonly --standalone -d memory.yourdomain.com
# Update .env
MCP_HTTPS_ENABLED=true
MCP_SSL_CERT_FILE=/etc/letsencrypt/live/memory.yourdomain.com/fullchain.pem
MCP_SSL_KEY_FILE=/etc/letsencrypt/live/memory.yourdomain.com/privkey.pem
# Restart server
python -m mcp_memory_service.server
Option 3: Reverse Proxy (Caddy)
The simplest production setup — Caddy handles HTTPS automatically:
memory.yourdomain.com {
reverse_proxy localhost:8765
}
That's it. Caddy auto-provisions Let's Encrypt certificates.
Cost Analysis
mcp-memory-service (Self-Hosted)
- Unlimited memories
- Unlimited users
- Full data ownership
- Knowledge graph included
- No vendor lock-in
Typical SaaS Memory
- 10k-100k memory limit
- Per-seat pricing
- Data on vendor's cloud
- Basic features only
- Vendor lock-in
Self-hosted on a Hetzner CX21 (2 vCPU, 4GB RAM) at ~$6/month. DigitalOcean ~$12, AWS t3.small ~$15.
Real-World Use Cases
Personal Assistant
Preferences, habits, schedules. "I prefer morning meetings after 10 AM."
Project Context
Architecture decisions, API endpoints, team roles. Never re-explain your stack.
Learning Tracker
Concepts learned, areas for review, helpful resources. Build on prior knowledge.
Code Review Helper
Coding styles, common gotchas, testing requirements. Institutional knowledge.
Multi-Device Workflow
Start on laptop, continue on tablet, pick up on phone. Same memory everywhere.
Team Knowledge Base
Shared decisions, onboarding context, best practices. OAuth-based team access.
Monitoring & Maintenance
# Health check
curl https://your-domain.com/api/health
# Database backup
cp ./data/memories.db ./backups/memories-$(date +%Y%m%d).db
# Server logs (systemd)
journalctl -u mcp-memory-service -f
Troubleshooting
| Problem | Solution |
|---|---|
| "Connection refused" | Check firewall (ufw allow 8765/tcp), verify MCP_SSE_HOST=0.0.0.0 |
| "OAuth callback error" | Verify callback URLs include claude.ai and claude.com |
| "SSL certificate error" | Use valid cert (not self-signed). Cloudflare Tunnel handles this automatically. |
| "Claude doesn't see connector" | Verify URL includes /mcp path. Check server logs. |
| "Max token limit exceeded" | Use search filters and pagination (25k token limit per tool result) |
Conclusion
Adding persistent memory to Claude doesn't have to be complicated or expensive.
With mcp-memory-service and Remote MCP, you get:
- Browser-based workflow (no desktop app)
- Enterprise security (OAuth 2.0, HTTPS)
- Full data ownership (self-hosted)
- Advanced features (knowledge graph, auto-consolidation, hybrid search)
- Cost-effective ($6/month vs $50+/month SaaS)
Setup takes 5 minutes. The value lasts forever.
Ready to Give Claude a Memory?
Open source. Self-hosted. 5 minutes to set up.
View on GitHub Full DocumentationResources
- mcp-memory-service on GitHub
- Official MCP Documentation
- Anthropic: Building Custom Connectors
- Cloudflare Tunnel Documentation
- MCP Remote Server Submission Guide
About the Author — Henry (doobidoo) is a Senior Technical Consultant and DevOps Engineer specializing in cloud infrastructure and AI tooling. He built mcp-memory-service out of frustration with vendor lock-in and lack of browser-based memory solutions for Claude.
Connect on GitHub.