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.
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.
terminalcodex mcp add context7 -- npx -y @upstash/context7-mcp
~/.codex/config.toml[mcp_servers.context7]
command = "npx"
args = ["-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.
terminalcodex mcp add notion --url https://mcp.notion.com/mcp
~/.codex/config.toml[mcp_servers.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 usemcpServers; Codex uses TOML tables. - If
npxisn't found, the app may not see your shell's PATH (common with nvm). Use the full path tonpx. - Restart the agent or reload the window after editing.
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
How to add an MCP server to Codex
Portable agent skills: one SKILL.md for every coding agent
Safe “always allow” rules for Claude Code and Codex CLI
Codex sandbox modes and approval policies explained
How to install the OpenAI Codex CLI
Agent Skills moves to the Agentic AI Foundation: what changes
MCP security: the risks in MCP servers and how to lock them down
What is AGENTS.md? The open instruction file for coding agents
Codex skills: create, install and use SKILL.md skills in Codex
GPT-6.1 Terra in Codex and the API: setup, pricing and limits
MCP OAuth: connect a remote MCP server in Claude Code, Codex and Cursor
Codex config.toml: location, precedence and the settings to change
Codex on Windows: native sandbox setup, WSL and fixes
Fix spawn npx ENOENT when starting an MCP server
MCP connection closed: find why a server will not connect
Claude Code vs OpenAI Codex: documented features compared
OpenAI Codex vs Cursor: documented features compared
OpenAI Codex vs GitHub Copilot: documented features compared
OpenAI Codex pricing and usage limits
AGENTS.md vs CLAUDE.md vs Cursor rules
AGENTS.md templates for Laravel and Next.js
MCP servers that work in every coding agent