Free toolGenerate .mcp.json configs for Claude Code, Cursor & Codex →
X

OpenAI · Codex CLI · IDE extension · ChatGPT desktop app

OpenAI Codex config file: where it lives & format

OpenAI Codex MCP config file: where ~/.codex/config.toml lives, its format and copy-paste examples. For the full walkthrough, see the step-by-step guide.

Step-by-step guideHow to add an MCP server to Codex →The full walkthrough with verification and troubleshooting. This page is the quick config reference.

1. Find the config file

  • ~/.codex/config.toml (user)
  • .codex/config.toml (project, trusted projects only)

One [mcp_servers.<name>] table per server. The CLI, IDE extension and ChatGPT desktop app share this config.

2. Add a local (stdio) server

Example: Context7, which runs locally with npx.

terminal
codex mcp add context7 -- npx -y @upstash/context7-mcp

3. Add a remote (HTTP) server

Example: Notion's hosted server. You sign in with OAuth the first time it connects.

terminal
codex mcp add notion --url https://mcp.notion.com/mcp

4. If it won't connect

  • Validate the file. One trailing comma breaks the whole file.
  • Check the top-level key: VS Code uses servers; Claude Code, Cursor and Antigravity use mcpServers; Codex uses TOML tables.
  • If npx isn't found, the app may not see your shell's PATH (common with nvm). Use the full path to npx.
  • Restart the agent or reload the window after editing.
Generate your config →

Codex MCP options worth knowing

Codex keeps MCP servers in config.toml: ~/.codex/config.toml by default, or a project-scoped .codex/config.toml in trusted projects. The CLI and the IDE extension share this configuration. Adding an OAuth server does not sign you in; run the login command separately. Add a stdio server with codex mcp add name -- command, passing variables with --env, list servers with codex mcp list, and start OAuth with codex mcp login name. In the TUI, /mcp shows active servers. Run codex mcp --help to see every MCP subcommand the CLI offers.

Per-server keys in config.toml give finer control. startup_timeout_sec defaults to 10 seconds and tool_timeout_sec to 60, which slow servers may need raised. enabled_tools is an allow list and disabled_tools a deny list applied after it, a simple way to hide destructive tools. For HTTP servers, bearer_token_env_var names an environment variable whose value is sent as the bearer token, so the token never sits in the file.

Source: developers.openai.com · Checked Oct 24, 2026

Frequently asked questions

~/.codex/config.toml (user) or .codex/config.toml (project, trusted projects only).

Guides, pricing & comparisons