## Prerequisites

- Mem0 Platform account ( [Sign up here](https://app.mem0.ai/?utm_source=oss&utm_medium=platform-mem0-mcp))
- API key ( [Get one from dashboard](https://app.mem0.ai/settings/api-keys?utm_source=oss&utm_medium=platform-mem0-mcp))
- Node.js 14+ (for npx)
- An MCP-compatible client (Claude, Claude Code, Codex, Cursor, Windsurf, VS Code, OpenCode)

## 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. The cloud-hosted MCP server requires no local installation: just connect and start using memory.

## Quick Setup

Add Mem0 MCP to your preferred clients with a single command:

```
npx mcp-add \
  --name mem0-mcp \
  --type http \
  --url "https://mcp.mem0.ai/mcp" \
  --clients "claude,claude code,cursor,windsurf,vscode,opencode"
```

This automatically configures Mem0 MCP for all supported clients at once.

## 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 |
| `list_events` | List memory operation events with filters and pagination |
| `get_event_status` | Check the status of an async memory operation by `event_id` |

## Client-Specific Setup

You can also configure individual clients:

### Claude Desktop

```
npx mcp-add \
  --name mem0-mcp \
  --type http \
  --url "https://mcp.mem0.ai/mcp" \
  --clients "claude"
```

Or manually add to your Claude Desktop configuration (`claude_desktop_config.json`):

```
{
  "mcpServers": {
    "mem0-mcp": {
      "type": "http",
      "url": "https://mcp.mem0.ai/mcp"
    }
  }
}
```

### Claude Code

```
npx mcp-add \
  --name mem0-mcp \
  --type http \
  --url "https://mcp.mem0.ai/mcp" \
  --clients "claude code"
```

### Codex

**Direct MCP (fastest, MCP only).** Codex reads MCP servers from `~/.codex/config.toml` as TOML (not JSON). Add:

```
[mcp_servers.mem0]
url = "https://mcp.mem0.ai/mcp"
bearer_token_env_var = "MEM0_API_KEY"
```

Export `MEM0_API_KEY` in the shell you launch Codex from, then restart Codex. `codex mcp add` only supports stdio servers, so HTTP servers must be added via `config.toml` directly, or via the **Plugins → Connect to a custom MCP → Streamable HTTP** UI in the Codex app.

**Sideloaded plugin (full experience).** If you want the memory protocol skill, Mem0 SDK skill, and opt-in lifecycle hooks alongside the MCP server, sideload the plugin from a clone of `mem0ai/mem0`. The repo ships a marketplace manifest at `.agents/plugins/marketplace.json`, so you can register it with one CLI call:

```
git clone https://github.com/mem0ai/mem0.git ~/codex-plugins/mem0-source
codex plugin marketplace add ~/codex-plugins/mem0-source
```

Then run `codex` and `/plugins`, browse the **Mem0 Plugins** marketplace, and install **Mem0**. Don’t combine this with the Direct MCP setup above; the sideloaded plugin auto-registers `mem0` via `.codex-mcp.json`, so a manual `[mcp_servers.mem0]` block would create a duplicate.

### Cursor

```
npx mcp-add \
  --name mem0-mcp \
  --type http \
  --url "https://mcp.mem0.ai/mcp" \
  --clients "cursor"
```

Or go to Cursor → Settings → MCP and add:

```
{
  "mcpServers": {
    "mem0-mcp": {
      "type": "http",
      "url": "https://mcp.mem0.ai/mcp"
    }
  }
}
```

### Windsurf

```
npx mcp-add \
  --name mem0-mcp \
  --type http \
  --url "https://mcp.mem0.ai/mcp" \
  --clients "windsurf"
```

### VS Code

```
npx mcp-add \
  --name mem0-mcp \
  --type http \
  --url "https://mcp.mem0.ai/mcp" \
  --clients "vscode"
```

### OpenCode

```
npx mcp-add \
  --name mem0-mcp \
  --type http \
  --url "https://mcp.mem0.ai/mcp" \
  --clients "opencode"
```

## Verify Your Setup

Once configured, your AI client can:

- Automatically save information with `add_memory`
- Search memories with `search_memories`
- Update memories with `update_memory`
- Delete memories with `delete_memory`

## 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.
```

If you get “Connection failed”, ensure you have a valid API key from [Mem0 Dashboard](https://app.mem0.ai/settings/api-keys?utm_source=oss&utm_medium=platform-mem0-mcp).

## Quick Recovery

- **“Connection refused”** → Check your internet connection and ensure the MCP client is correctly configured
- **“Invalid API key”** → Get a new key from [Mem0 Dashboard](https://app.mem0.ai/settings/api-keys?utm_source=oss&utm_medium=platform-mem0-mcp)
- **“npx command not found”** → Install Node.js from [nodejs.org](https://nodejs.org/)

## Next steps

- [Platform Quickstart](https://docs.mem0.ai/platform/quickstart) - direct SDK/API integration guide
- [MCP Specification](https://modelcontextprotocol.io/) - the Model Context Protocol standard
- [Gemini with Mem0 MCP](https://docs.mem0.ai/cookbooks/frameworks/gemini-3-with-mem0-mcp) - example integration cookbook
