--- title: "Mem0 MCP" description: "Connect any AI client to Mem0 using Model Context Protocol in minutes" icon: "puzzle-piece" estimatedTime: "~5 minutes" --- **Prerequisites** - Mem0 Platform account ([Sign up here](https://app.mem0.ai)) - API key ([Get one from dashboard](https://app.mem0.ai/settings/api-keys)) - Python 3.10+, Docker, or Node.js 14+ - An MCP-compatible client (Claude Desktop, Cursor, or custom agent) ## What is Mem0 MCP? Mem0 MCP Server exposes Mem0's memory capabilities as MCP tools, letting AI agents decide when to save, search, or update information. ## Deployment Options Choose from three deployment methods: 1. **Python Package (Recommended)** - Install locally with `uvx` for instant setup 2. **Docker Container** - Isolated deployment with HTTP endpoint 3. **Smithery** - Remote hosted service for managed deployments ## Available Tools The MCP server exposes these memory tools to your AI client: | Tool | Description | |------|-------------| | `add_memory` | Save text or conversation history for a user/agent | | `search_memories` | Semantic search across existing memories with filters | | `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 confirming the ID | | `delete_memory` | Delete a single memory by `memory_id` | | `delete_all_memories` | Bulk delete all memories in scope | | `delete_entities` | Delete a user/agent/app/run entity and its memories | | `list_entities` | Enumerate users/agents/apps/runs stored in Mem0 | --- ## Quickstart with Python (UVX) ```bash uv pip install mem0-mcp-server ``` Add this to your MCP client (e.g., Claude Desktop): ```json { "mcpServers": { "mem0": { "command": "uvx", "args": ["mem0-mcp-server"], "env": { "MEM0_API_KEY": "m0-...", "MEM0_DEFAULT_USER_ID": "your-handle" } } } } ``` Set your environment variables: ```bash export MEM0_API_KEY="m0-..." export MEM0_DEFAULT_USER_ID="your-handle" ``` ```bash # Clone the mem0-mcp repository git clone https://github.com/mem0ai/mem0-mcp.git cd mem0-mcp # Set your API keys export MEM0_API_KEY="m0-..." export OPENAI_API_KEY="sk-openai-..." # Run the interactive agent python example/pydantic_ai_repl.py ``` **Sample Interactions:** ``` User: Remember that I love tiramisu Agent: Got it! I've saved that you love tiramisu. User: What do you know about my food preferences? Agent: Based on your memories, you love tiramisu. User: Update my project: the mobile app is now 80% complete Agent: Updated your project status successfully. ``` Your AI client can now: - Automatically save information with `add_memory` - Search memories with `search_memories` - Update memories with `update_memory` - Delete memories with `delete_memory` If you get "Connection failed", ensure your API key is valid and the server is running. --- ## Quickstart with Docker ```bash docker build -t mem0-mcp-server https://github.com/mem0ai/mem0-mcp.git ``` ```bash docker run --rm -d \ --name mem0-mcp \ -e MEM0_API_KEY="m0-..." \ -p 8080:8081 \ mem0-mcp-server ``` For clients that connect via HTTP (instead of stdio): ```json { "mcpServers": { "mem0-docker": { "command": "curl", "args": ["-X", "POST", "http://localhost:8080/mcp", "--data-binary", "@-"], "env": { "MEM0_API_KEY": "m0-..." } } } } ``` ```bash # Check container logs docker logs mem0-mcp # Test HTTP endpoint curl http://localhost:8080/health ``` The container should start successfully and respond to HTTP requests. If port 8080 is occupied, change it with `-p 8081:8081`. --- ## Quickstart with Smithery (Hosted) For the simplest integration, use Smithery's hosted Mem0 MCP server - no installation required. **Example: One-click setup in Cursor** 1. Visit [smithery.ai/server/@mem0ai/mem0-memory-mcp](https://smithery.ai/server/@mem0ai/mem0-memory-mcp) and select Cursor as your client ![Smithery Mem0 MCP Configuration](/images/smithery-mem0-mcp.png) 2. Open Cursor → Settings → MCP 3. Click `mem0-mcp` → Initiate authorization 4. Configure Smithery with your environment: - `MEM0_API_KEY`: Your Mem0 API key - `MEM0_DEFAULT_USER_ID`: Your user ID - `MEM0_ENABLE_GRAPH_DEFAULT`: Optional, set to `true` for graph memories 5. Return to Cursor settings and wait for tools to load 6. Start chatting with Cursor and begin storing preferences **For other clients:** Visit [smithery.ai/server/@mem0ai/mem0-memory-mcp](https://smithery.ai/server/@mem0ai/mem0-memory-mcp) to connect any MCP-compatible client with your Mem0 credentials. --- ## Quick Recovery - **"uvx command not found"** → Install with `pip install uv` or use `pip install mem0-mcp-server` instead. Make sure your Python environment has `uv` installed (or system-wide). - **"Connection refused"** → Check that the server is running and the correct port is configured - **"Invalid API key"** → Get a new key from [Mem0 Dashboard](https://app.mem0.ai/settings/api-keys) - **"Permission denied"** → Ensure Docker has access to bind ports (try with `sudo` on Linux) --- ## Next Steps ## Additional Resources - **[Mem0 MCP Repository](https://github.com/mem0ai/mem0-mcp)** - Source code and examples - **[Platform Quickstart](/platform/quickstart)** - Direct API integration guide - **[MCP Specification](https://modelcontextprotocol.io)** - Learn about MCP protocol