# Claude Code

> Connect MMW to Claude Code with one command, using the local agent and, with your consent, session history.

On this page you will connect MMW to Claude Code, verify the connection and, if you want, turn on session history upload.

## What you get

- The `remember`, `search`, `forget`, `validate_memory` and `gateway_call` tools in every Claude Code session.
- The read-only `mmw_sync_status` tool, when you connect through the local agent.
- Claude Code session history upload, only after you explicitly consent in a terminal.
- The same memory that Cursor, Codex and claude.ai see with the same key.

## Prerequisites

- An MMW API key (starts with `mmw_`); see the [Quickstart](/start/quickstart/).
- Claude Code with the `claude` command in your terminal.
- For the local agent: Python 3.11+ and [uv](https://docs.astral.sh/uv/) (the `uvx` command).

## Setup

1. Run in a terminal:

   ```bash
   claude mcp add mmw -s user \
     -e MMW_API_KEY=mmw_your_key \
     -e MMW_ENDPOINT=https://mcp.mmwhub.tech \
     -- uvx --from https://app.mmwhub.tech/downloads/mmw-agent/mmw_agent-0.1.4-py3-none-any.whl mmw-agent
   ```

   The `-s user` flag makes MMW available in every project. Without it the server is added for the current directory only.

2. Restart Claude Code if it was open.

3. Verify the connection (see below).

The command writes an `mcpServers.mmw` block to `~/.claude.json`. You can also add it by hand:

```json title="~/.claude.json"
{
  "mcpServers": {
    "mmw": {
      "command": "uvx",
      "args": ["--from", "https://app.mmwhub.tech/downloads/mmw-agent/mmw_agent-0.1.4-py3-none-any.whl", "mmw-agent"],
      "env": {
        "MMW_API_KEY": "mmw_your_key",
        "MMW_ENDPOINT": "https://mcp.mmwhub.tech"
      }
    }
  }
}
```

Nothing to install, but no session history and no `mmw_sync_status`.

1. Run in a terminal:

   ```bash
   claude mcp add --transport http mmw https://mcp.mmwhub.tech/mcp -s user \
     --header "Authorization: Bearer mmw_your_key"
   ```

2. Restart Claude Code and verify the connection.

## Verify

1. In a terminal run `claude mcp list`: the `mmw` server should be listed as connected.

2. Inside a Claude Code session type `/mcp`: the `mmw` server shows `remember`, `search`, `forget`, `validate_memory` and `gateway_call`, plus `mmw_sync_status` when connected through the agent.

3. Ask:

   ```text
   Remember in MMW: staging is deployed with the systemd unit app-staging. Fact key: deploy-staging.
   ```

   Claude Code calls `remember` and reports the record ID with the `unverified` status.

4. Open a new session and ask:

   ```text
   How do we deploy staging? Check MMW.
   ```

   Expected answer: the assistant calls `search` and replies that staging is deployed with `app-staging`, citing the MMW record.

You can check the agent on its own, without Claude Code:

```bash
MMW_API_KEY=mmw_your_key MMW_ENDPOINT=https://mcp.mmwhub.tech \
  uvx --from https://app.mmwhub.tech/downloads/mmw-agent/mmw_agent-0.1.4-py3-none-any.whl mmw-agent status
```

## Session history (optional)

The agent can upload your Claude Code history to MMW, but only after a **person** confirms consent in an interactive terminal. A model or a script cannot grant consent.

```bash
mmw-agent consent   # shows how many sessions it found and asks for permission
mmw-agent revoke    # withdraw consent: uploads stop immediately
```

If `mmw-agent` is not installed globally, run it as `uvx --from <wheel URL> mmw-agent consent` with the same `MMW_API_KEY` and `MMW_ENDPOINT`.

User and assistant messages, tool calls and tool results are uploaded; model reasoning, system prompts, file snapshots and paths are not. Secrets are removed on your computer before sending and once more on the server. See [Session history](/agent/session-history/).

Uploaded sessions are stored, but search over them and fact extraction are not available yet: they do not appear in `search` results.

## Common problems

Usually `uvx` is not found or Python is older than 3.11. Run `uvx --version` and `python3 --version`. If `uvx` is installed but Claude Code cannot find it, put its full path in the config (find it with `which uvx`).

The key is missing, revoked or expired. Check `MMW_API_KEY` in `~/.claude.json` and issue a new key in your account if needed.

The server was added without `-s user`, so it applies to the current directory only. Remove it (`claude mcp remove mmw`) and add it again with `-s user`.

For other errors see [Errors](/reference/errors/) and [Agent troubleshooting](/agent/troubleshooting/).

## What's next
