# Codex

> Connect MMW to Codex through the local agent for memory across sessions and, with your consent, session history.

On this page you will connect MMW to Codex through `config.toml`, verify the connection and, if you want, turn on Codex session history upload.

## What you get

- The `remember`, `search`, `forget`, `validate_memory`, `gateway_call` and `mmw_sync_status` tools in Codex.
- Codex session history upload, only after you explicitly consent in a terminal.
- Memory shared with Claude Code, Cursor and claude.ai when you use the same key.

## Prerequisites

- An MMW API key (starts with `mmw_`); see the [Quickstart](/start/quickstart/).
- Codex with MCP server support.
- Python 3.11+ and [uv](https://docs.astral.sh/uv/) (the `uvx` command).

## Where the config lives

```text
~/.codex/config.toml
```

```text
~/.codex/config.toml
```

```text
%USERPROFILE%\.codex\config.toml
```

## Setup

1. Open `config.toml` (create it if it does not exist).

2. Add this section:

   ```toml title="~/.codex/config.toml"
   [mcp_servers.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" }
   ```

3. Restart Codex.

If your Codex version supports remote MCP servers over HTTP, you can also connect directly: URL `https://mcp.mmwhub.tech/mcp`, header `Authorization: Bearer mmw_your_key`. The parameter names for this depend on the Codex version, so check its documentation. A direct connection has no `mmw_sync_status` and no session history upload.

## Verify

1. In the Codex interface type `/mcp` (or run `codex mcp list` in a terminal, in versions that have this command). The `mmw` server should be listed with `remember`, `search`, `forget`, `validate_memory`, `gateway_call` and `mmw_sync_status`.

2. Ask:

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

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

3. In a new session ask:

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

   Expected answer: Codex calls `search` and replies that staging is deployed with `app-staging`.

## Session history (optional)

The agent can upload your Codex session history, but only after a **person** confirms consent in an interactive terminal:

```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 consent
```

To withdraw consent, run the same command with `revoke` instead of `consent`: uploads stop immediately. From inside Codex you can check the state with the `mmw_sync_status` tool.

Model reasoning, system prompts, file snapshots and paths are never uploaded; secrets are removed on your computer before sending and once more on the server. Search over uploaded sessions is not available yet. See [Session history](/agent/session-history/).

## Common problems

Check the TOML syntax: `env` is an inline table in curly braces, and strings use double quotes. Make sure `uvx` is available (`uvx --version`) and Python 3.11+ is installed. If needed, put the full path to `uvx` in `command`.

On first launch `uvx` downloads the agent, which can take longer than Codex waits by default. Run `mmw-agent status` once from a terminal (the command above with `status`) so the wheel is cached, or raise the MCP server start-up timeout in the Codex settings; the parameter name depends on the version.

The key is missing, revoked or expired. Check `MMW_API_KEY` in `config.toml` and issue a new key if needed.

## What's next
