Skip to main content
Model Context Protocol (MCP) provides a standardized way for AI agents to manage their own memory through Mem0, without manual API calls.

Why use MCP

When building AI applications, memory management often requires manual integration. MCP eliminates this complexity by:
  • Universal compatibility: Works with any MCP-compatible client (Claude Desktop, Cursor, custom agents)
  • Agent autonomy: AI agents decide when to save, search, or update memories
  • Zero infrastructure: No servers to maintain - Mem0 handles everything
  • Standardized protocol: One integration works across all your AI tools

Available tools

The MCP server exposes 9 memory tools to your AI client:
ToolPurpose
add_memoryStore conversations or facts
search_memoriesFind relevant memories with filters
get_memoriesList memories with pagination
update_memoryModify existing memory content
delete_memoryRemove specific memories
delete_all_memoriesBulk delete memories
delete_entitiesRemove user/agent/app entities
get_memoryRetrieve single memory by ID
list_entitiesView stored entities

Deployment options

Choose the deployment method that fits your workflow:
Containerized deployment with HTTP endpoint:
docker build -t mem0-mcp-server https://github.com/mem0ai/mem0-mcp.git
docker run --rm -d -e MEM0_API_KEY="m0-..." -p 8080:8081 mem0-mcp-server
Configure for HTTP:
{
  "mcpServers": {
    "mem0-docker": {
      "command": "curl",
      "args": ["-X", "POST", "http://localhost:8080/mcp", "--data-binary", "@"],
      "env": {
        "MEM0_API_KEY": "m0-..."
      }
    }
  }
}
One-click setup with managed service:Visit smithery.ai/server/@mem0ai/mem0-memory-mcp and:
  1. Select your AI client (Cursor, Claude Desktop, etc.)
  2. Configure your Mem0 API key
  3. Set your default user ID
  4. Enable graph memory (optional)
  5. Copy the generated configuration
Your client connects automatically - no installation required.

Configuration

Required environment variables

MEM0_API_KEY="m0-..."                    # Your Mem0 API key
MEM0_DEFAULT_USER_ID="your-handle"        # Default user ID

Optional variables

MEM0_ENABLE_GRAPH_DEFAULT="true"          # Enable graph memories
MEM0_MCP_AGENT_MODEL="gpt-4o-mini"        # LLM for bundled examples
The included Pydantic AI agent provides an interactive REPL to test memory operations:
# Install the package
pip install mem0-mcp-server

# Set your API keys
export MEM0_API_KEY="m0-..."
export OPENAI_API_KEY="sk-openai-..."

# Clone and test with the agent
git clone https://github.com/mem0ai/mem0-mcp.git
cd mem0-mcp-server
python example/pydantic_ai_repl.py
Testing different server configurations:
  • Local server (default): python example/pydantic_ai_repl.py
  • Docker container:
    export MEM0_MCP_CONFIG_PATH=example/docker-config.json
    export MEM0_MCP_CONFIG_SERVER=mem0-docker
    python example/pydantic_ai_repl.py
    
  • Smithery remote:
    export MEM0_MCP_CONFIG_PATH=example/config-smithery.json
    export MEM0_MCP_CONFIG_SERVER=mem0-memory-mcp
    python example/pydantic_ai_repl.py
    
Try these test prompts:
  • “Remember that I love tiramisu”
  • “Search for my food preferences”
  • “Update my project: the mobile app is now 80% complete”
  • “Show me all memories about project Phoenix”
  • “Delete memories from 2023”

How the testing works

  1. Configuration loads - Reads from example/config.json by default
  2. Server starts - Launches or connects to the Mem0 MCP server
  3. Agent connects - Pydantic AI agent (Mem0Guide) attaches to the server
  4. Interactive REPL - You get a chat interface to test all memory operations

Example interactions

Once connected, your AI agent can:
User: Remember that I'm allergic to peanuts
Agent: [calls add_memory] Got it! I've saved your peanut allergy.

User: What dietary restrictions do I know about?
Agent: [calls search_memories] You have a peanut allergy.
The agent automatically decides when to use memory tools based on context.

Try these prompts

# Multi-task operations
"Generate 5 user personas for our e-commerce app with different demographics, store them all, then search for existing personas"

# Natural context retrieval
"Anything about my work preferences I should remember?"

# Complex information updates
"Update my current project: the mobile app is now 80% complete, we've fixed the login issues, and the launch date is March 15"

# Time-based queries
"What meetings did I have last week about Project Phoenix?"

# Memory cleanup
"Delete all test data and temporary memories from our development phase"

# Personal preferences
"I drink oat milk cappuccino with one sugar every morning, and I prefer standing desks"

# Health and wellness tracking
"I'm allergic to peanuts and shellfish, and I go for 5km runs on weekday mornings"
These examples demonstrate how MCP enables natural language memory operations - the AI agent automatically determines when to add, search, update, or delete memories based on context.

What you can do

The Mem0 MCP server enables powerful memory capabilities for your AI applications:
  • Health tracking: “I’m allergic to peanuts and shellfish” - Add new health information
  • Research data: “Store these trial parameters: 200 participants, double-blind, placebo-controlled” - Save structured data
  • Preference queries: “What do you know about my dietary preferences?” - Search and retrieve relevant memories
  • Project updates: “Update my project status: the mobile app is now 80% complete” - Modify existing memory
  • Data cleanup: “Delete all memories from 2023” - Bulk remove outdated information
  • Topic overview: “Show me everything about Project Phoenix” - List all memories for a subject

Performance tips

  • Enable graph memories for relationship-aware recall
  • Use specific filters when searching large memory sets
  • Batch operations when adding multiple memories
  • Monitor memory usage in the Mem0 dashboard

Best practices

  • Start simple: Use the Python package for development
  • Use wildcards: user_id: "*" to search across all users
  • Test locally: Use the bundled Python agent to verify setup
  • Monitor usage: Track memory operations in the dashboard
  • Document patterns: Share successful prompt patterns with your team