Configuration · troubleshooting record
Codex config.toml fails to parse an MCP table
Codex reads MCP servers from TOML tables such as [mcp_servers.name]. A parse error usually comes from invalid table syntax, duplicate keys, a value of the wrong type, or a nested table declared in an invalid order.
Symptoms
- Codex reports a TOML parse error and may ignore the whole configuration.
- `codex mcp list` does not show the expected server.
- Editing one server breaks other Codex settings in the same file.
Confirmed causes
These causes have a documented basis. They may not be the cause of your specific failure.
Duplicate table or key declaration
TOML forbids defining the same key or table twice; duplicate [mcp_servers.<name>] blocks are invalid.
Arrays or inline tables with incorrect quoting
Codex expects args as an array of strings and headers as a TOML table or inline table of string values.
A dotted name or unquoted value that is not valid TOML
TOML bare keys and strings have specific syntax; names with spaces or dots require quoting.
Possible causes
- Pasting a JSON object into the TOML file.
- Using the wrong key, such as serverUrl or bearerTokenEnvVar, from another client's format.
- Trailing content after a table that changes the current table context.
- A TOML parser version that rejects a newer inline-table syntax used by the file.
What still needs verification
- Whether the error points at the MCP table or at an unrelated section of the same file.
- Whether Codex is reading the global file or a project .codex/config.toml.
- The current Codex version's accepted keys (the MCP CLI is marked experimental).
Affected environments
Fixes
Parse the file with a TOML parser
- Paste the file into the Config Doctor and select Codex, or run it through a TOML parser.
- Fix the first reported syntax error, then re-run because TOML parsers stop early.
- Do not convert the file to JSON; Codex uses TOML.
Rebuild the MCP table from a known-good template
- Use a [mcp_servers.<name>] table with command and args for stdio.
- Use url, optional bearer_token_env_var, and http_headers for remote servers.
- Keep unrelated Codex settings outside the mcp_servers tables.
Verify the fix
- The Config Doctor parses the TOML with no errors.
- `codex mcp list` shows the server.
- The server connects and exposes tools in a Codex session.
Paste the configuration into the Config Doctor. It runs in your browser, never uploads the file, and can show structural issues and safe fixes.
Why we believe this
- developers.openai.com/codex/mcpOfficial documentation · checked Oct 23, 2026 · documented
Codex documents MCP configuration through mcp_servers TOML tables and the codex mcp commands.
- modelcontextprotocol.io/specification/2026-07-28/basic/index#error-codesOfficial documentation · checked Oct 23, 2026 · documented
The specification defines JSON-RPC error codes and MCP-specific error codes for the 2026-07-28 protocol version.