What is MCP in Codex CLI?
MCP (Model Context Protocol) lets Codex use tools that live outside it. An MCP server is a program or a remote service that offers tools, such as “search notes” or “save this fact”. Codex CLI, the desktop app and the IDE extension all load the same MCP servers, so you set a server up once.
How do you add an MCP server?
Codex has two kinds of server, and each one has its own setup:
| Server type | Command | Use it for |
|---|---|---|
| Local (stdio) | codex mcp add <name> -- <command> [args] | A program that runs on your machine, such as npx -y <package> |
| Remote (Streamable HTTP) | codex mcp add <name> --url <url> | A service you reach at an address |
The official example adds Context7, a free documentation server:
1codex mcp add context7 -- npx -y @upstash/context7-mcp
Put the server’s own command after the --. Pass a setting such as an API key to a local server with --env KEY=VALUE. Remote servers can also take a bearer token from an environment variable. You can set that in config.toml with bearer_token_env_var.
What does config.toml look like?
The CLI command writes a table to config.toml. You can also write it by hand. Each server gets its own [mcp_servers.<name>] table:
1[mcp_servers.context7]
2command = "npx"
3args = ["-y", "@upstash/context7-mcp"]
4
5[mcp_servers.example]
6url = "https://mcp.example.com"
A local server uses command, args, env and cwd. A remote server uses url, plus bearer_token_env_var or http_headers for auth. Leave secrets out of the file where you can: env_vars forwards a variable from your shell instead of writing its value down.
Four settings are worth knowing:
| Setting | Default | What it does |
|---|---|---|
startup_timeout_sec | 10 | How long Codex waits for the server to start |
tool_timeout_sec | 60 | How long one tool call may run |
enabled | true | Set false to turn a server off without deleting it |
enabled_tools / disabled_tools | none | Allow list, then a deny list, for the server’s tools |
Codex has a top-level mcp_optional_startup_grace_ms setting too (default 1000 ms). It controls how long Codex waits for optional servers when it builds the first tool list.
How do you check, log in and remove a server?
1codex mcp list # list configured servers
2codex mcp login <name> # sign in to a server that uses OAuth
3codex mcp --help # all MCP commands
Inside the codex TUI, type /mcp to see the active servers. If the terminal has no local browser, use codex mcp login <name> --no-browser, open the printed link yourself and paste the redirect URL back. To turn a server off, set enabled = false in its table. To remove it, delete its table from config.toml.
Memory: which MCP servers give Codex memory?
An MCP server gives Codex memory only if it saves facts and returns them later. Two options:
A file-based memory server. The official Knowledge Graph Memory Server (
@modelcontextprotocol/server-memory) stores entities in a local JSONL file. Point it at a file in your home folder withMEMORY_FILE_PATH, and check the server’s README for its current settings:1[mcp_servers.memory] 2command = "npx" 3args = ["-y", "@modelcontextprotocol/server-memory"] 4 5[mcp_servers.memory.env] 6MEMORY_FILE_PATH = "/Users/you/.codex/memory.jsonl"Hindsight. Hindsight is an open-source memory server, MIT licensed, and the full server is in the open-source release. Its Coding Agents package supports Codex CLI:
npx @vectorize-io/hindsight-coding-agents install codexwrites three hooks to~/.codex/hooks.jsonand an[mcp_servers]entry toconfig.toml. The hooks needcodex_hooks = truein that file. The package’s steps are in Codex CLI install. Hindsight Cloud also runs an MCP server athttps://api.hindsight.vectorize.io/mcpwith OAuth and no API key, according to its Grok Bot integration docs (read 2026-10-24). We did not test that URL in Codex, so check the Hindsight docs before you rely on it.On the numbers, Hindsight reports 64.1 on BEAM 10M against Mem0’s 48.6. Mem0’s own comparison page gives both figures, so this is Mem0’s data, not an independent test. The limits matter too: each save calls an LLM, and retrieval can return a lot of context by default. Lower the context size if the prompt gets too big.
Codex only uses memory tools when it decides to. Add a line to AGENTS.md, such as “Search memory before you answer questions about past decisions”. Otherwise it may never call them. For the full picture, see Codex memory and AI memory MCP servers. Skills are a different feature: they add instructions, not memory. See Codex skills. For every config key, see the Codex CLI config reference.
Sources
- OpenAI, Codex MCP docs, developers.openai.com/codex/mcp (read 2026-11-13; the page now redirects to the ChatGPT Learn site): add command,
config.tomlkeys, timeouts,enabled_tools,codex mcp login,/mcp. - Codex CLI install page on this site, for the Hindsight Coding Agents command.
- Hindsight Grok Bot integration README (read 2026-10-24), for the hosted MCP URL. Not tested in Codex.
- Benchmark figures: Mem0’s comparison page, not Hindsight’s own report.