> ## Documentation Index
> Fetch the complete documentation index at: https://mem0-feature-memo-claude-plugin-v1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Mem0 MCP

> Connect any AI client to Mem0 using Model Context Protocol in minutes

<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 theme={null}
npx mcp-add \
  --name mem0-mcp \
  --type http \
  --url "https://mcp.mem0.ai/mcp" \
  --clients "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](#client-specific-setup).

<Note>
  Claude Desktop is not in the list above: it rejects the `mcp-add` command. Add it through Settings instead, see [Claude Desktop](#client-specific-setup) below.
</Note>

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:

| 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 and/or metadata 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:

<AccordionGroup>
  <Accordion title="Claude Desktop">
    Claude Desktop does not support the `mcp-add` command, it rejects the server as "not a valid MCP server." Add the Mem0 server through the Settings UI instead:

    1. Open Claude Desktop and go to **Settings > Connectors**.
    2. Click **Add custom connector**.
    3. Enter a name (for example `mem0-mcp`) and the URL `https://mcp.mem0.ai/mcp`.
    4. Save, then restart Claude Desktop.

    The first time you use a Mem0 tool, Claude Desktop opens a browser window to sign in, see [Signing in](#signing-in).
  </Accordion>

  <Accordion title="Claude Code">
    ```bash theme={null}
    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 theme={null}
    [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 theme={null}
    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 theme={null}
    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 theme={null}
    {
      "mcpServers": {
        "mem0-mcp": {
          "type": "http",
          "url": "https://mcp.mem0.ai/mcp"
        }
      }
    }
    ```
  </Accordion>

  <Accordion title="Windsurf">
    ```bash theme={null}
    npx mcp-add \
      --name mem0-mcp \
      --type http \
      --url "https://mcp.mem0.ai/mcp" \
      --clients "windsurf"
    ```
  </Accordion>

  <Accordion title="VS Code">
    ```bash theme={null}
    npx mcp-add \
      --name mem0-mcp \
      --type http \
      --url "https://mcp.mem0.ai/mcp" \
      --clients "vscode"
    ```
  </Accordion>

  <Accordion title="OpenCode">
    ```bash theme={null}
    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 see                                | What it means                                             | What to do                                                                                                                                            |
| ------------------------------------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `401` or "Authentication required"          | The client connected but is not signed in                 | Complete the browser sign-in, or set your API key as a bearer token                                                                                   |
| "Connection refused" or "failed to connect" | The client cannot reach the server                        | Check your internet connection, then confirm the URL is exactly `https://mcp.mem0.ai/mcp`                                                             |
| The agent has no Mem0 tools                 | The config was written but the client has not reloaded it | Restart the client. If the tools are still missing, check that `mcp-add` wrote to the config file your client actually reads                          |
| `npx: command not found`                    | Node.js is not installed                                  | Install it from [nodejs.org](https://nodejs.org)                                                                                                      |
| "Invalid API key"                           | The key is wrong, revoked, or from a different account    | Get 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

* [Platform quickstart](/platform/quickstart): call Mem0 from your own code instead of through an agent
* [Mem0 CLI](/platform/cli): the same operations from your terminal
* [MCP specification](https://modelcontextprotocol.io): the Model Context Protocol standard
* [Gemini with Mem0 MCP](/cookbooks/frameworks/gemini-3-with-mem0-mcp): a worked example
