Skip to main content

Model Context Protocol server that exposes the Mem0 long-term memory API as tools

Project description

Mem0 MCP Server

PyPI version License: Apache 2.0

mem0-mcp-server wraps the official Mem0 Memory API as a Model Context Protocol (MCP) server so any MCP-compatible client (Claude Desktop, Cursor, custom agents) can add, search, update, and delete long-term memories.

Tools

The server exposes the following tools to your LLM:

Tool Description
add_memory Save text or conversation history (or explicit message objects) for a user/agent.
search_memories Semantic search across existing memories (filters + limit supported).
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 once the user confirms the memory_id.
delete_memory Delete a single memory by memory_id.
delete_all_memories Bulk delete all memories in the confirmed scope (user/agent/app/run).
delete_entities Delete a user/agent/app/run entity (and its memories).
list_entities Enumerate users/agents/apps/runs stored in Mem0.

All responses are JSON strings returned directly from the Mem0 API.

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
  2. Docker - Containerized deployment that creates an /mcp HTTP endpoint
  3. Smithery - Remote hosted service for managed deployments

Quick Start

Installation

uv pip install mem0-mcp-server

Or with pip:

pip install mem0-mcp-server

Client Configuration

Add this configuration to your MCP client:

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

Test with the Python Agent

Click to expand: Test with the Python Agent

To test the server immediately, use the included Pydantic AI agent:

# Install the package
pip install mem0-mcp-server
# Or with uv
uv pip install mem0-mcp-server

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

# Clone and test with the agent
git clone https://github.com/mem0ai/mem0-mcp-server.git
cd mem0-mcp-server
python example/pydantic_ai_repl.py

Using different server configurations:

# Use with Docker container
export MEM0_MCP_CONFIG_PATH=example/docker-config.json
export MEM0_MCP_CONFIG_SERVER=mem0-docker
python example/pydantic_ai_repl.py

# Use with Smithery remote server
export MEM0_MCP_CONFIG_PATH=example/config-smithery.json
export MEM0_MCP_CONFIG_SERVER=mem0-memory-mcp
python example/pydantic_ai_repl.py

What You Can Do

The Mem0 MCP server enables powerful memory capabilities for your AI applications:

  • Remember that I'm allergic to peanuts and shellfish - Add new health information to memory
  • Store these trial parameters: 200 participants, double-blind, placebo-controlled study - Save research data
  • What do you know about my dietary preferences? - Search and retrieve all food-related memories
  • Update my project status: the mobile app is now 80% complete - Modify existing memory with new info
  • Delete all memories from 2023, I need a fresh start - Bulk remove outdated memories
  • Show me everything I've saved about the Phoenix project - List all memories for a specific topic

Configuration

Environment Variables

  • MEM0_API_KEY (required) – Mem0 platform API key.
  • MEM0_DEFAULT_USER_ID (optional) – default user_id injected into filters and write requests (defaults to mem0-mcp).
  • MEM0_MCP_AGENT_MODEL (optional) – default LLM for the bundled agent example (defaults to openai:gpt-4o-mini).

Advanced Setup

Click to expand: Docker, Smithery, and Development

Docker Deployment

To run with Docker:

  1. Build the image:

    docker build -t mem0-mcp-server .
    
  2. Run the container:

    docker run --rm -d \
      --name mem0-mcp \
      -e MEM0_API_KEY=sk_mem0_... \
      -p 8080:8081 \
      mem0-mcp-server
    
  3. Monitor the container:

    # View logs
    docker logs -f mem0-mcp
    
    # Check status
    docker ps
    

Running with Smithery Remote Server

To connect to a Smithery-hosted server:

  1. Install the MCP server (Smithery dependencies are now bundled):

    pip install mem0-mcp-server
    
  2. Configure MCP client with 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": "sk_mem0_..."
          }
        }
      }
    }
    

Development Setup

Clone and run from source:

git clone https://github.com/mem0ai/mem0-mcp-server.git
cd mem0-mcp-server
pip install -e ".[dev]"

# Run locally
mem0-mcp-server

# Or with uv
uv sync
uv run mem0-mcp-server

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mem0_mcp_server-0.2.1.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mem0_mcp_server-0.2.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file mem0_mcp_server-0.2.1.tar.gz.

File metadata

  • Download URL: mem0_mcp_server-0.2.1.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for mem0_mcp_server-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c3504727a2ccaca682fce09971fecce4121a0b7fdb66ee593bf5d16af894ec04
MD5 cdf42dc9b7f7039b4d7d86634222dc0b
BLAKE2b-256 fa4ef54298d342cf5ee4c22ec1e49ba5d944f30d867dddf5a37522b2849e6903

See more details on using hashes here.

File details

Details for the file mem0_mcp_server-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mem0_mcp_server-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 32c3808db6eba23137ed36fe2db4709a6b15f43bb308c6a62c0a836c26b70a33
MD5 44d8f2b6da396795e2d98267f2f6752b
BLAKE2b-256 a28fd932ca05b26d23f5b72cfdb67779a4cfa7743e644d8885b191f229f4ba48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page