Persistent, cross-device memory layer for Claude Code using Mem0 Platform
This project integrates Mem0 Platform with Claude Code to provide intelligent, persistent memory across all your devices. Claude Code will remember your coding preferences, project context, and past decisions automatically.
- π§ Persistent Memory - Remembers across sessions and devices
- π Cross-Device Sync - Same memory on laptop, desktop, and cloud VMs
- π― Context-Aware - Automatically recalls relevant information
- π Secure - API keys managed via environment variables
- π Modular Design - Clean separation of concerns
The easiest way to get started:
# Clone the repository
git clone https://github.com/ankurkakroo2/memory-setup-claude.git
cd memory-setup-claude
# Run the interactive setup wizard
./setup.shThe interactive setup wizard will guide you through:
- β Prerequisites checking
- β Mem0 account setup
- β API key configuration
- β Environment file creation
- β MCP configuration
- β Validation testing
Features:
- π¨ Beautiful colored terminal UI
- π Step-by-step guidance
- β Automatic validation
- π Secure configuration
If you prefer manual setup:
- Claude Code installed (Install guide)
- Python 3.10+ with
uvpackage manager - Mem0 Platform account (Sign up)
-
Clone and navigate to the repository
cd /Users/ankur/D/Playground/memory-setup-claude -
Configure environment variables
# Copy the example file cp .env.example .env # Edit .env and add your credentials nano .env
Update these values:
export MEM0_API_KEY="m0-your-actual-api-key" export MEM0_DEFAULT_USER_ID="your-username" export MEM0_ENABLE_GRAPH_DEFAULT="false"
-
Load environment variables
source .env -
Configure MCP for Claude Code
The
~/.mcp.jsonfile should already be configured. Verify it exists:cat ~/.mcp.json -
Test the integration
claude --print --dangerously-skip-permissions "Remember that I prefer TypeScript"
Add to your shell profile to automatically load environment variables:
echo 'source /Users/ankur/D/Playground/memory-setup-claude/.env' >> ~/.zshrc
source ~/.zshrcSee LLD.md for detailed architecture documentation including:
- System architecture diagrams
- Data flow sequences
- Modular code structure
- Security design
- Performance considerations
memory-setup-claude/
βββ .env # Your config (git-ignored)
βββ .env.example # Template for .env
βββ .gitignore # Git ignore rules
βββ setup.sh # π Interactive setup wizard
βββ test_claude_memory.sh # Validation script
βββ README.md # This file
βββ LLD.md # Low-level design document
βββ claude-mem0.env.example # Legacy template
source .env
claude --print --dangerously-skip-permissions "Remember I prefer pytest over unittest"Later:
claude --print --dangerously-skip-permissions "What's my Python testing preference?"claude --print --dangerously-skip-permissions "Search my memories for programming preferences"| Variable | Description | Example |
|---|---|---|
MEM0_API_KEY |
Your Mem0 Platform API key | m0-xxx... |
MEM0_DEFAULT_USER_ID |
Your unique user identifier | ankur@example.com |
MEM0_ENABLE_GRAPH_DEFAULT |
Enable graph memory features | false |
{
"mcpServers": {
"mem0": {
"command": "uvx",
"args": ["mem0-mcp-server"],
"env": {
"MEM0_API_KEY": "${MEM0_API_KEY}",
"MEM0_DEFAULT_USER_ID": "${MEM0_DEFAULT_USER_ID}",
"MEM0_ENABLE_GRAPH_DEFAULT": "${MEM0_ENABLE_GRAPH_DEFAULT:-false}"
}
}
}
}To use the same memory across multiple devices:
- Install Claude Code and UV on each device
- Copy configuration files:
.env(with your API key)- Ensure
~/.mcp.jsonis configured
- Use the SAME
MEM0_DEFAULT_USER_IDon all devices - Source the environment before running Claude Code
All devices will automatically share the same memory!
brew install uv # macOS
# or
pip install uv- Verify
~/.mcp.jsonexists and is valid JSON - Check that environment variables are loaded:
echo $MEM0_API_KEY - Restart Claude Code completely
- Verify your API key in
.env - Generate a new key at app.mem0.ai/settings/api-keys
- Ensure no extra spaces or quotes in the
.envfile
- Confirm you're using the same
MEM0_DEFAULT_USER_IDon all devices - Check the Mem0 dashboard to verify memories are being saved
- Ensure all devices have network access to Mem0 Platform
Claude Code has access to these MCP tools:
add_memory- Save new informationsearch_memories- Find relevant memoriesget_memories- List all memoriesget_memory- Retrieve specific memory by IDupdate_memory- Modify existing memorydelete_memory- Remove specific memorydelete_all_memories- Bulk deletedelete_entities- Remove entity and its memorieslist_entities- View stored entities
- β
Never commit
.envfiles to git - β Rotate API keys regularly
- β
Use different
user_idfor different contexts if needed - β Review memories periodically in Mem0 dashboard
- β Don't share your
.envfile - β Don't hardcode API keys in code
- β Don't use the same API key for public projects
Run the validation script to test your setup:
./test_claude_memory.shThis will verify:
- β Environment variables are loaded correctly
- β MCP server starts successfully
- β Claude Code recognizes memory tools
- β All prerequisites are installed
- Claude Code Documentation
- Mem0 Platform
- Mem0 Documentation
- Model Context Protocol
- Low-Level Design Document
This is a personal integration project. For contributions to:
- Claude Code: Visit Claude Code docs
- Mem0: Visit Mem0 GitHub
This integration setup is for personal use. Refer to:
Last Updated: January 7, 2026 Status: Validated & Production Ready β