Mem0 MCP server

Integrates with mem0.ai to store, retrieve, and semantically search coding preferences, snippets, and programming knowledge through a persistent FastMCP server using SSE connections.
Back to servers
Setup instructions
Provider
mem0
Release date
Mar 18, 2025
Language
Python
Stats
524 stars

The Mem0 MCP Server wraps the official Mem0 Memory API as a Model Context Protocol (MCP) server, allowing any MCP-compatible client (like Claude Desktop, Cursor, or custom agents) to work with long-term memories through adding, searching, updating, and deleting operations.

Tools Provided

The server provides the following memory management tools to your LLM:

Tool Description
add_memory Save text or conversation history for a user/agent
search_memories Perform semantic search across existing memories
get_memories List memories with structured filters and pagination
get_memory Retrieve one memory by its memory_id
update_memory Overwrite a memory's text after user confirmation
delete_memory Delete a single memory by memory_id
delete_all_memories Bulk delete all memories in the confirmed scope
delete_entities Delete a user/agent/app/run entity and its memories
list_entities Enumerate users/agents/apps/runs stored in Mem0

Installation

You can install the Mem0 MCP Server using uv:

uv pip install mem0-mcp-server

Or with standard pip:

pip install mem0-mcp-server

Configuration

Environment Variables

  • MEM0_API_KEY (required) – Your Mem0 platform API key
  • MEM0_DEFAULT_USER_ID (optional) – Default user ID for requests (defaults to mem0-mcp)
  • MEM0_ENABLE_GRAPH_DEFAULT (optional) – Enable graph memories (defaults to false)
  • MEM0_MCP_AGENT_MODEL (optional) – Default LLM for the bundled agent example

Client Setup

Add this configuration to your MCP client:

{
  "mcpServers": {
    "mem0": {
      "command": "uvx",
      "args": ["mem0-mcp-server"],
      "env": {
        "MEM0_API_KEY": "m0-...",
        "MEM0_DEFAULT_USER_ID": "your-handle"
      }
    }
  }
}

Usage Options

There are three ways to use the Mem0 MCP Server:

1. Python Package

Install and run locally using uvx with any MCP client as shown in the configuration above.

2. Docker Deployment

For containerized deployment:

docker build -t mem0-mcp-server .

Run the container:

docker run --rm -d \
  --name mem0-mcp \
  -e MEM0_API_KEY=m0-... \
  -p 8080:8081 \
  mem0-mcp-server

3. Smithery Remote Server

Configure your MCP client to use Smithery:

{
  "mcpServers": {
    "mem0-memory-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@smithery/cli@latest",
        "run",
        "@mem0ai/mem0-memory-mcp",
        "--key",
        "your-smithery-key",
        "--profile",
        "your-profile-name"
      ],
      "env": {
        "MEM0_API_KEY": "m0-..."
      }
    }
  }
}

Example Usage

The Mem0 MCP server enables these memory capabilities:

  • Remember personal information: "Remember that I'm allergic to peanuts and shellfish"
  • Store data: "Store these trial parameters: 200 participants, double-blind, placebo-controlled study"
  • Retrieve preferences: "What do you know about my dietary preferences?"
  • Update information: "Update my project status: the mobile app is now 80% complete"
  • Delete memories: "Delete all memories from 2023, I need a fresh start"
  • Search by topic: "Show me everything I've saved about the Phoenix project"

Testing with the Python Agent

To quickly test functionality, use the included Pydantic AI agent:

# 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

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mem0" '{"command":"uv","args":["run","main.py"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mem0": {
            "command": "uv",
            "args": [
                "run",
                "main.py"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mem0": {
            "command": "uv",
            "args": [
                "run",
                "main.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later