Mem0 MCP Server

Mem0 MCP Server

Provides long-term memory capabilities for MCP clients by wrapping the Mem0 API, enabling semantic search, storage, retrieval, and management of conversation memories across users and agents.

Category
访问服务器

README

Mem0 MCP Server

PyPI version License: MIT

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.

Ways to Run

You can run this server in three modes depending on your setup:

  • Local Stdio (Recommended): Best for Claude Desktop, Cursor, or local development. No server port management needed.
  • Smithery: Best for deploying as a hosted HTTP endpoint or using the Smithery platform.
  • Docker: Best for containerized deployments where you need an HTTP endpoint.

How to Connect

Claude Desktop & Cursor (Stdio)

The easiest way to use Mem0 is by letting uvx handle the installation. Add this configuration to your claude_desktop_config.json or Cursor MCP settings:

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

Manual Installation (CLI)

If you prefer installing the package yourself:

pip install mem0-mcp-server

Then run it directly:

export MEM0_API_KEY="sk_mem0_..."
mem0-mcp-server

Agent Example

This repository includes a standalone agent (powered by Pydantic AI) to test the server interactively.

# Clone repo & install deps
git clone https://github.com/mem0-ai/mem0-mcp-server.git
cd mem0-mcp-server
pip install -e ".[smithery]"

# Run the agent REPL
export MEM0_API_KEY="sk_mem0_..."
export OPENAI_API_KEY="sk-openai-..."
python example/pydantic_ai_repl.py

This launches "Mem0Guide". Try prompts like "search memories for favorite food" to test your API key and memory storage.

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.

Config Files

For advanced usage (like switching the agent example to use Docker), this repo includes standard MCP config files in the example/ directory:

  • example/config.json: Local Stdio (default)
  • example/docker-config.json: Docker HTTP

Switch configurations for the agent REPL by setting MEM0_MCP_CONFIG_PATH.

Detailed Setup Guides

<details> <summary><strong>Click to expand: Smithery, Docker, and Troubleshooting</strong></summary>

1. Smithery HTTP

To run the HTTP transport with Smithery:

  1. pip install -e ".[smithery]" (or pip install "mem0-mcp-server[smithery]").
  2. Ensure MEM0_API_KEY (and optional MEM0_DEFAULT_USER_ID) are exported.
  3. uv run smithery dev for a local endpoint (http://127.0.0.1:8081/mcp).
  4. Optional: uv run smithery playground to open an ngrok tunnel + Smithery web UI.
  5. Testing: Create a config copying example/config.json but changing the entry to { "type": "http", "url": "http://127.0.0.1:8081/mcp" }, then point MEM0_MCP_CONFIG_PATH to it before running the agent REPL.
  6. Hosted deploy: Push to GitHub, connect at smithery.ai, click Deploy.

2. Docker HTTP

To containerize the server:

  1. Build the image:
    docker build -t mem0-mcp-server .
    
  2. Run the container (ensure env vars are passed):
    docker run --rm -e MEM0_API_KEY=sk_mem0_... -p 8081:8081 mem0-mcp-server
    
  3. Connect clients using example/docker-config.json:
    export MEM0_MCP_CONFIG_PATH="$PWD/example/docker-config.json"
    python example/pydantic_ai_repl.py
    

Troubleshooting Docker:

  • The container must be running before HTTP clients connect.
  • Ensure MEM0_API_KEY is passed via -e.
  • If clients can't connect, check that port 8081 is forwarded correctly (-p 8081:8081) and that the config URL is reachable.

3. FAQ / Troubleshooting

  • RuntimeWarning: 'mem0_mcp_server.server' found in sys.modules…: Harmless warning when running the Pydantic AI REPL.
  • session_config not found in request scope: Expected when running outside Smithery; the server falls back to environment variables.
  • Smithery CLI "server reference not found": Ensure [tool.smithery] server = "mem0_mcp_server.server:create_server" is present in pyproject.toml.

</details>

Development

uv sync --python 3.11                  # optional, installs dev extras and lockfile
uv run --from . mem0-mcp-server        # run local checkout via uvx

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选