Codex MCP servers: add, approve and debug them
Add an MCP server to Codex with codex mcp add or config.toml, stop the approval prompt on every tool call, and fix a server that won’t start.
Updated
To add an MCP server to Codex, run codex mcp add <name> -- <command> for a local server or codex mcp add <name> --url <address> for a hosted one, or write a [mcp_servers.<name>] table in ~/.codex/config.toml. Type /mcp inside Codex to see which servers are connected. The Codex CLI, the IDE extension and the ChatGPT desktop app share that file, so a server you add once works in all three.
The part most setup posts skip: Codex asks before running MCP tools that can change things, and approval_policy = "never" doesn’t turn those prompts off. Each server and each tool has its own approval setting.
As of November 2026, from OpenAI’s Codex MCP docs and configuration reference. OpenAI changes these often, so its pages win if they disagree.
MCP tools stop Codex for approval, and the prompt sits in a terminal you aren’t looking at. Coral puts every waiting Codex session in your Mac’s notch, so you answer with one key. Download Coral for free
Add an MCP server to Codex
| What you want | Command |
|---|---|
| A local server (runs as a process) | codex mcp add context7 -- npx -y @upstash/context7-mcp |
| A local server that needs a variable | codex mcp add <name> --env API_KEY=value -- <command> |
| A hosted server at a URL | codex mcp add <name> --url https://mcp.example.com/mcp |
| Sign in to an OAuth server | codex mcp login <name> (add --no-browser on a machine with no browser) |
| See what’s configured | codex mcp list |
| See every MCP subcommand | codex mcp --help |
| See connected servers and their tools | /mcp inside Codex |
codex mcp add writes to ~/.codex/config.toml. For a server only one repo needs, put the table in that repo’s .codex/config.toml instead; Codex reads it only in projects you’ve trusted. In the desktop app or the IDE extension, it’s Settings → MCP servers → Add server, then restart.
The same two servers written by hand:
# A local (STDIO) server
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
env_vars = ["CONTEXT7_API_KEY"] # forward this variable from your shell
# A hosted (streamable HTTP) server
[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"
Keep tokens in environment variables (env_vars, bearer_token_env_var, env_http_headers) rather than as values in the file, especially for a project config that lives in git. For OAuth servers, leave the token settings out and run codex mcp login <name>; Codex stores the credentials itself.
If you’d rather not type key names, the Codex config.toml generator builds [mcp_servers] tables along with your sandbox and approval settings.
Why Codex asks before every MCP tool call
Codex treats an MCP tool call like a shell command: if the tool can change something, it may stop and ask. Playwright and browser servers are the usual pain, with a prompt for every click and keystroke. Users in openai/codex#13476 report that it started with Codex 0.105, most likely because Codex began reading the tools’ own “this changes things” metadata, and that approval_policy = "never" doesn’t suppress these prompts.
The fix is the per-server and per-tool approval setting:
| Setting | What Codex does |
|---|---|
default_tools_approval_mode = "prompt" | Asks before every tool on this server |
default_tools_approval_mode = "writes" | Asks only for tools that aren’t marked read-only |
default_tools_approval_mode = "approve" | Runs this server’s tools without asking |
default_tools_approval_mode = "auto" | Leaves it to Codex’s own approval rules |
[mcp_servers.<name>.tools.<tool>] approval_mode = "..." | Overrides the server setting for one tool |
enabled_tools = [...] / disabled_tools = [...] | Allow list and deny list for the server’s tools; the deny list is applied after the allow list |
The meanings of prompt and writes are from OpenAI’s docs. That approve runs a tool without asking is from Codex’s source, as quoted in openai/codex#29857.
A setup that trusts what’s safe and keeps the prompts that matter:
# Docs lookups can't change anything: no prompts
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
default_tools_approval_mode = "approve"
# A tracker: reading is fine, writing asks
[mcp_servers.tracker]
url = "https://mcp.example.com/mcp"
bearer_token_env_var = "TRACKER_TOKEN"
default_tools_approval_mode = "writes"
disabled_tools = ["delete_issue"] # turned off entirely
# A browser: approve navigation, ask for the rest
[mcp_servers.playwright]
command = "npx"
args = ["-y", "@playwright/mcp@latest"]
default_tools_approval_mode = "prompt"
[mcp_servers.playwright.tools.browser_navigate]
approval_mode = "approve"
Tools from a plugin take the same settings under [plugins."<plugin>".mcp_servers.<server>].
Headless runs. In codex exec, which can’t show a prompt, MCP calls that need approval come back as user cancelled MCP tool call. openai/codex#24135 and #29857 report this happening even with "approve" set. Test your MCP tools in a short codex exec run before you build CI or an overnight job on them.
The prompts you keep are the ones worth reading. Coral shows a waiting Codex MCP call in your Mac’s notch with the tool, the server and its full input, and you answer with one key. Get Coral for free
Why your Codex MCP server doesn’t show up
Open /mcp first. Then check these in order:
| What you see | Likely cause | Fix |
|---|---|---|
Server missing from /mcp | It’s in a project .codex/config.toml and the project isn’t trusted, or enabled = false | Trust the project, or move the table to ~/.codex/config.toml |
| Server listed but fails to start | It took longer than the 10-second startup timeout (first npx runs download packages) | startup_timeout_sec = 30 |
| Tools missing from the first turn, there later | Codex waits only 1 second for optional servers when it builds the first tool list | mcp_optional_startup_grace_ms = 0 to wait for each server’s full timeout |
| You’d rather it fail loudly | Optional servers start quietly in the background | required = true makes startup fail if the server isn’t ready |
| Server needs sign-in | OAuth server with no stored login | codex mcp login <name> |
| One tool is missing | It’s filtered by enabled_tools, or listed in disabled_tools (applied after the allow list) | Fix the lists |
| A tool call times out | Over the 60-second tool timeout | tool_timeout_sec = 120 |
| A tool’s output gets cut | Over the model’s output budget | [mcp_servers.<name>.tools.<tool>] output_token_limit = 30000 |
| The server can’t find its API key | The variable isn’t passed to the process | Add it to env_vars, or set it under [mcp_servers.<name>.env] |
Codex as an MCP server
The other half of the “codex mcp server” question, running Codex itself as an MCP server so Claude Code or another agent can call it, no longer works with the built-in command. OpenAI has removed codex mcp-server and the standalone codex-mcp-server binary. Posts and cookbooks that still show npx -y codex mcp-server predate that. OpenAI’s replacements are the Codex app server, for integrations that need sign-in, history, approvals and streamed events, and the Codex SDK for scripts and CI.
Community wrappers that call the Codex CLI from an MCP server still exist; check that one is maintained before you rely on it.
Codex MCP vs Claude Code MCP
| Codex | Claude Code | |
|---|---|---|
| Add a server | codex mcp add | claude mcp add |
| Config | [mcp_servers] in ~/.codex/config.toml or .codex/config.toml | .mcp.json or your Claude settings |
| Per-tool approval | approval_mode per tool, default_tools_approval_mode per server | Permission rules on mcp__server__tool names |
| Hooks on MCP calls | Match mcp__server__tool in Codex hooks | Match mcp__server__tool in Claude Code hooks |
For the rest of the comparison, see Codex vs Claude Code.
Where Coral fits
Coral’s Codex hooks watch every tool, MCP tools included. When a Codex session stops to ask about an MCP call, it shows up in your Mac’s notch next to your Claude Code, Copilot, OpenCode and Grok sessions, whoever has waited longest first:
- See what it wants to run. The card names the tool and the server and shows the full input, not just “Allow?”.
- Answer with one key. Press 1, 2 or 3 from any app; ⌘Z takes it back within two seconds.
- Away from your Mac. Alerts on your iPhone are Free; answering from the phone is Pro. The phone can only deny an MCP call whose tool name looks like a delete or whose input holds a secret; allowing that one needs the Mac.
Set approve for the servers you trust and writes for the rest, and Coral makes sure the prompts that are left don’t stall a long run like a Codex /goal.
Questions
How do I add an MCP server to Codex?
Run codex mcp add <name> -- <command> for a local server, or codex mcp add <name> --url <address> for a hosted one. You can also add a [mcp_servers.<name>] table to ~/.codex/config.toml. Type /mcp in Codex to check it connected.
Where is the Codex MCP config?
In ~/.codex/config.toml, under one [mcp_servers.<name>] table per server. A repo can have its own in .codex/config.toml, which Codex loads only for trusted projects. The CLI, the IDE extension and the ChatGPT desktop app all read the same file.
How do I stop Codex asking for approval on MCP tools?
Set default_tools_approval_mode = "approve" on a server you trust, or "writes" to be asked only for tools that can change things. Override single tools with [mcp_servers.<name>.tools.<tool>] approval_mode. approval_policy = "never" alone doesn’t stop MCP prompts.
Does Codex support remote MCP servers?
Yes. Codex connects to streamable HTTP servers with a url, using a bearer token from an environment variable, static or environment-based headers, or OAuth via codex mcp login.
Can I run Codex as an MCP server?
Not with the built-in command anymore: OpenAI removed codex mcp-server. Use the Codex app server for integrations or the Codex SDK for scripts.
Why does my Codex MCP server time out on startup?
Codex gives a server 10 seconds to start, and a first npx run often needs longer to download the package. Raise startup_timeout_sec for that server.