Codex MCP config: config.toml and mcp_servers
Codex is the only major MCP client that uses TOML. Its servers are tables in ~/.codex/config.toml, it has a proper enabled switch, and one config serves the desktop app, the command line and the IDE extension. This page covers the shape of an entry, the commands and the details that cost people an afternoon.
| What | macOS | Windows |
|---|---|---|
| Config file | ~/.codex/config.toml | %USERPROFILE%\.codex\config.toml |
| Project config | .codex/config.toml in a trusted project | |
| Plugins | ~/.codex/plugins | %USERPROFILE%\.codex\plugins |
| Format and key | TOML, one [mcp_servers.<name>] table per server | |
One config, several front ends. The ChatGPT desktop app, the codex command-line tool and the IDE extension share this configuration, so a server you add for one is available in the others.
The shape of an entry
A local server needs a command. Arguments, environment variables and timeouts are optional.
[mcp_servers.my-server]
command = "npx"
args = ["-y", "some-mcp-package"]
startup_timeout_sec = 20
enabled = true
[mcp_servers.my-server.env]
API_KEY = "value"
A remote server uses a url instead, with optional bearer_token_env_var, http_headers and auth.
[mcp_servers.my-remote]
url = "https://example.com/mcp"
bearer_token_env_var = "MY_TOKEN"
Other documented options on both kinds are cwd for local servers, tool_timeout_sec and required.
From the command line
codex mcp add <server-name> -- <command>
codex mcp list
codex mcp login <server-name>
codex mcp login handles OAuth for a remote server. Run codex mcp --help for the rest.
Two details that trip people up
- Switching a server off keeps its definition. Set
enabled = falseon the server’s own table. Nothing has to be commented out or parked elsewhere, which makes this the cleanest off-switch of the five clients covered here. - Removing a server means removing two tables. Environment variables live in a separate
[mcp_servers.<name>.env]table, and leaving that one behind is a common and confusing leftover.
The file is bigger than it looks
A real config.toml carries dozens of [projects."…"] tables that record per-directory history. None of that should move when you add a server, so edit it in a TOML-aware way and keep a copy first.
Plugins under ~/.codex/plugins can bundle their own .mcp.json, which uses the ordinary mcpServers JSON shape rather than TOML. Those files sit in a cache directory the client repopulates, so editing them by hand does not last.
If the ChatGPT desktop app cannot find npx or uvx while the codex command works in your terminal, the app was most likely launched without your shell’s PATH. Put the full path in command; the reasoning is in why your MCP server is not showing up.