Back to Mem0

Mem0 MCP

docs/platform/mem0-mcp.mdx

2.0.159.1 KB
Original Source
<Info> **Prerequisites** - Mem0 Platform account (<a href="https://app.mem0.ai?utm_source=oss&utm_medium=platform-mem0-mcp" rel="nofollow">Sign up here</a>) - API key (<a href="https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=platform-mem0-mcp" rel="nofollow">Get one from dashboard</a>) - Node.js 18+ (for npx) - An MCP-compatible client (Claude, Claude Code, Codex, Cursor, Windsurf, VS Code, OpenCode) </Info>

What is Mem0 MCP?

MCP (Model Context Protocol) is a standard way for AI clients to call external tools. The Mem0 MCP server hands your agent a set of memory tools, so it can decide for itself when to save something, look something up, or update what it already knows. Nothing runs on your machine: the server is hosted by Mem0, and your client connects to it over HTTPS.

Memories you store this way live in your Mem0 account, not on your computer.

Quick setup

Point your clients at the hosted server with a single command:

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

mcp-add is a helper that writes the Mem0 server into each client's own MCP config file, so you do not have to edit them by hand. Name only the clients you actually use. If you would rather see the change yourself, every client's manual config is under Client-specific setup.

Restart each client afterwards so it picks up the new server.

Signing in

The server is authenticated, so connecting is not enough on its own. There are two ways in:

<Tabs> <Tab title="Sign in through the client"> Most clients handle this for you. The first time your agent uses a Mem0 tool, the client opens a browser window asking you to authorize access to your Mem0 account. Approve it once and the client stores the token, refreshing it as needed.
This is the easier path, and it is what happens by default if you followed the quick setup above.
</Tab> <Tab title="Use your API key"> For clients without browser sign-in, or for headless environments like CI, send your API key as a bearer token instead. Where you put it depends on the client; see [Client-specific setup](#client-specific-setup) for the exact syntax.
Get a key from the <a href="https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=platform-mem0-mcp" rel="nofollow">Mem0 dashboard</a>, and keep it out of any file you commit.
</Tab> </Tabs>

If neither is set up, the server replies 401 Authentication required and your client reports the connection as failed.

Available tools

The MCP server exposes these memory tools to your AI client:

ToolDescription
add_memorySave text or conversation history for a user/agent
search_memoriesSemantic search across existing memories with filters
get_memoriesList memories with structured filters and pagination
get_memoryRetrieve one memory by its memory_id
update_memoryOverwrite a memory's text and/or metadata after confirming the ID
delete_memoryDelete a single memory by memory_id
delete_all_memoriesBulk delete all memories in scope
delete_entitiesDelete a user/agent/app/run entity and its memories
list_entitiesEnumerate users/agents/apps/runs stored in Mem0
list_eventsList memory operation events with filters and pagination
get_event_statusCheck the status of an async memory operation by event_id

Client-specific setup

You can also configure individual clients:

<AccordionGroup> <Accordion title="Claude Desktop"> ```bash 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`):
```json
{
  "mcpServers": {
    "mem0-mcp": {
      "type": "http",
      "url": "https://mcp.mem0.ai/mcp"
    }
  }
}
```
</Accordion> <Accordion title="Claude Code"> ```bash npx mcp-add \ --name mem0-mcp \ --type http \ --url "https://mcp.mem0.ai/mcp" \ --clients "claude code" ``` </Accordion> <Accordion title="Codex"> **Direct MCP (fastest, MCP only).** Codex reads MCP servers from `~/.codex/config.toml` as TOML (not JSON). Add:
```toml
[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.

<Note>
  Codex uses the server name `mem0` (not `mem0-mcp` like the other clients on this page) so it matches the name the bundled plugin registers if you ever sideload it later.
</Note>

**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:

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

See the [Codex integration guide](/integrations/codex) for full details, lifecycle-hook setup, and management commands (`codex plugin marketplace upgrade` / `remove`).
</Accordion> <Accordion title="Cursor"> ```bash npx mcp-add \ --name mem0-mcp \ --type http \ --url "https://mcp.mem0.ai/mcp" \ --clients "cursor" ```
Or go to Cursor → Settings → MCP and add:
```json
{
  "mcpServers": {
    "mem0-mcp": {
      "type": "http",
      "url": "https://mcp.mem0.ai/mcp"
    }
  }
}
```
</Accordion> <Accordion title="Windsurf"> ```bash npx mcp-add \ --name mem0-mcp \ --type http \ --url "https://mcp.mem0.ai/mcp" \ --clients "windsurf" ``` </Accordion> <Accordion title="VS Code"> ```bash npx mcp-add \ --name mem0-mcp \ --type http \ --url "https://mcp.mem0.ai/mcp" \ --clients "vscode" ``` </Accordion> <Accordion title="OpenCode"> ```bash npx mcp-add \ --name mem0-mcp \ --type http \ --url "https://mcp.mem0.ai/mcp" \ --clients "opencode" ``` </Accordion> </AccordionGroup>

Check that it worked

Restart your client, then ask it to store something and read it back in a later message:

You:   Remember that I prefer TypeScript over JavaScript for new projects.
Agent: Saved.

You:   What language do I prefer for new projects?
Agent: You prefer TypeScript over JavaScript.

The second answer only works if the memory was really stored, so this is a genuine round-trip test rather than the model repeating itself.

Two things to look for while you do it:

  • Your client should show the Mem0 tools among its available tools. Most clients list them in a tools or MCP panel.
  • The first tool call should trigger the browser sign-in described above, unless you configured an API key.

To confirm from outside the client, open the <a href="https://app.mem0.ai/dashboard?utm_source=oss&utm_medium=platform-mem0-mcp" rel="nofollow">Mem0 dashboard</a>: anything the agent saved appears there.


Troubleshooting

What you seeWhat it meansWhat to do
401 or "Authentication required"The client connected but is not signed inComplete the browser sign-in, or set your API key as a bearer token
"Connection refused" or "failed to connect"The client cannot reach the serverCheck your internet connection, then confirm the URL is exactly https://mcp.mem0.ai/mcp
The agent has no Mem0 toolsThe config was written but the client has not reloaded itRestart the client. If the tools are still missing, check that mcp-add wrote to the config file your client actually reads
npx: command not foundNode.js is not installedInstall it from nodejs.org
"Invalid API key"The key is wrong, revoked, or from a different accountGet a new one from the <a href="https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=platform-mem0-mcp" rel="nofollow">Mem0 dashboard</a>

Next steps