Codex MCP server setup
To add an MCP server to Codex, run codex mcp add with the server name and its start command or URL, or add a [mcp_servers.name] table to ~/.codex/config.toml. Then run codex mcp list, or type /mcp inside Codex, to see that it loaded. The form below writes both for you.
How to use it
- 1
Describe the server
Pick a preset, or enter a name and either the command that starts a local server or the URL of a remote one. Write secrets as ${NAME} so the key stays in your environment.
- 2
Run the command or paste the TOML
Run the codex mcp add command in your terminal, or paste the TOML into ~/.codex/config.toml. Use .codex/config.toml in the repo when the server is for one trusted project only.
- 3
Check that Codex loaded it
Run codex mcp list in your shell, or type /mcp inside the Codex TUI to see the active servers. Start a new Codex session after you edit the file by hand.
Questions
How do I add an MCP server to Codex?
Run codex mcp add name -- command args for a local server, for example codex mcp add context7 -- npx -y @upstash/context7-mcp. For a remote server, run codex mcp add name --url https://example.com/mcp. Both write a [mcp_servers.name] table to ~/.codex/config.toml.
How do I check which MCP servers are enabled in Codex?
Run codex mcp list in your terminal to see every configured server. Inside the Codex TUI, type /mcp to see the servers that are active in this session. A server with enabled = false stays in config.toml but does not start.
Where is the Codex MCP config file?
Codex keeps MCP servers in ~/.codex/config.toml. You can also scope a server to one repo in .codex/config.toml, which Codex reads only in trusted projects. The Codex CLI, the IDE extension and the ChatGPT desktop app share this configuration, so you set a server up once.
How do I pass an API key to a Codex MCP server?
For a local server, env sets values and env_vars forwards variables that already exist in your shell, so the key never sits in the file. For a remote server, bearer_token_env_var names the variable that holds the token, and env_http_headers maps headers to variables. For OAuth servers, run codex mcp login name.
Why does my MCP server time out when Codex starts?
Codex waits 10 seconds for a server to start and 60 seconds for a tool call by default. A first npx download can take longer. Raise startup_timeout_sec or tool_timeout_sec in the server's table, or install the package once before you start Codex.
Can I paste a Claude or Cursor mcp.json into Codex?
No. Codex reads TOML, and a JSON mcpServers block does not load. Paste your JSON into the checker on this page, then copy the Codex output, which is the same server as a [mcp_servers.name] table.
Can Codex itself run as an MCP server?
Not any more. OpenAI's CLI reference says the codex mcp-server command and the standalone codex-mcp-server binary have been removed, and points to the Codex app server instead. Guides that still show codex mcp-server are out of date.
Sources
Every command, key and default on this page comes from OpenAI's Codex docs below. We checked them on 2026-11-12.
Related playbooks
- Test your local web app in a real browser and fix console errors in one loop
- Triage a production error from Sentry or logs into a tested fix pull request
- Map an unfamiliar codebase into a checked architecture document before you change it
More free tools
- MCP Config GeneratorWrite the MCP config file, path and install command for Claude, Codex, VS Code and Cursor.
- AGENTS.md GeneratorWrite a lean AGENTS.md for Codex, Cursor, Copilot and Claude Code, or check the one you have.
- CLAUDE.md GeneratorWrite a CLAUDE.md for Claude Code, share it with AGENTS.md, or check the one you have.
- SKILL.md ValidatorCheck a SKILL.md against the Agent Skills spec and get each fix, with the source for every rule.
- Claude Code Permissions BuilderBuild the permissions block of Claude Code's settings.json, with presets, plain rules and risk checks.
- Claude Code Cost CalculatorCompare Claude Code on the API with Pro, Max 5x and Max 20x, from your real token counts or an estimate.