ME

Mem0 MCP Server for Coding Preferences

Customize coding preferences with the Mem0 MCP server to streamline settings, synchronize profiles, and enforce best practices across projects.

Quick Install
npx -y @mem0ai/mem0-mcp

Overview

Mem0 MCP Server exposes the Mem0 Memory API as a Model Context Protocol (MCP) server so MCP-compatible clients (Claude Desktop, Cursor, VS Code extensions, custom agents) can persist, query, and manage long-term memories for users and agents. It acts as a lightweight HTTP/CLI bridge that standardizes memory operations (add, search, update, delete) for any tool that speaks MCP.

Note: this repository has been archived and is no longer actively maintained. Mem0 provides an official hosted MCP server; see the Mem0 docs for the current managed option. The archived server is still useful as a reference, local deployment, or for self-hosted scenarios. Source: https://github.com/mem0ai/mem0-mcp

Features

  • Standard MCP endpoint that forwards memory operations to the Mem0 Memory API
  • CRUD operations for memories (create, retrieve, update, delete) and entities (users/agents/apps/runs)
  • Semantic search across stored memories with filters and pagination
  • CLI / uvx-executable for running a local MCP server and quick integration with MCP clients
  • Docker-ready container for isolated deployments
  • Example Python agent for testing and demonstration
  • All tool responses are returned as raw JSON from the Mem0 API (no additional transformation)

Installation / Configuration

Install from PyPI:

pip install mem0-mcp-server
# OR (via uv)
uv pip install mem0-mcp-server

Run locally with uvx (example MCP server process):

uvx mem0-mcp-server

Minimum environment variables:

export MEM0_API_KEY="m0-..."                 # required
export MEM0_DEFAULT_USER_ID="your-handle"   # optional (default: mem0-mcp)
export MEM0_ENABLE_GRAPH_DEFAULT="false"    # optional
export MEM0_MCP_AGENT_MODEL="openai:gpt-4o-mini"  # optional for example agent

Example MCP client configuration (JSON snippet):

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

Docker quickstart:

# build
docker build -t mem0-mcp-server .

# run (exposes /mcp endpoint inside container)
docker run --rm -d \
  --name mem0-mcp \
  -e MEM0_API_KEY=m0-... \
  -p 8080:8081 \
  mem0-mcp-server

Testing with the included example Python agent:

# clone and run the REPL agent
git clone https://github.com/mem0ai/mem0-mcp.git
cd mem0-mcp-server
pip install -r requirements.txt
export MEM0_API_KEY="m0-..."
export OPENAI_API_KEY="sk-..."
python example/pydantic_ai_repl.py

Available Tools

The MCP server exposes these tools to connected LLMs and clients. Each tool returns raw JSON responses from Mem0.

ToolPurpose
add_memorySave text, conversation history, or structured message objects
search_memoriesSemantic search with filters and result limits
get_memoriesList memories with filter fields and pagination
get_memoryRetrieve a single memory by memory_id
update_memoryOverwrite or modify a memory after confirming memory_id
delete_memoryDelete a single memory by memory_id
delete_all_memoriesBulk delete all memories in a confirmed scope (user/agent/app/run)
delete_entitiesRemove an entity (user/agent/app/run) and its associated memories
list_entitiesEnumerate stored users, agents, apps, and runs

Use Cases

  • Personalization: persist preferences like coding style (indentation, preferred languages, testing approach) so assistants can apply them across sessions.
  • Project context: store project-specific details (architecture notes, component owners, deployment commands) to surface during code reviews or generation tasks.
  • Research logging: record experiment parameters and outcomes (trial size, configuration, results) for later retrieval and comparison.
  • Compliance / housekeeping: bulk-delete memories from a date range or remove an account’s memories when requested.
  • Agent coordination: share agent-visible context (current task, status, recent messages) across multiple agents or tools via the MCP layer.

Concrete examples:

  • “Remember that my projects prefer 2-space indentation and use pytest” → add_memory
  • “Find everything I’ve saved about feature flag toggles” → search_memories with a topic filter
  • “Update the Phoenix app status to 80% complete” → update_memory with confirmed memory_id
  • “Delete all memories tagged 2023” → delete_all_memories with scope filters

Notes and Next Steps

  • All responses are the Mem0 API JSON; client-side parsing may be required.
  • The repository is archived—consider using Mem0’s hosted MCP option for production use (see Mem0 docs).
  • For customization, the server is simple to extend: add middleware, enforce org-specific policies, or adapt filters to your authorization model.

Repository and reference: https://github.com/mem0ai/mem0-mcp (archived).