You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-c 'mcp_servers={}' is intended to clear all MCP servers for a single invocation, but it silently does nothing. TOML {} creates an empty inline table that merges non-destructively with the existing config, leaving all servers enabled.
Repro
# config.toml has MCP servers defined
codex mcp list
# Shows: context7 (enabled), fetcher (enabled), tavily (enabled), ...# Attempt to clear all servers
codex mcp list -c 'mcp_servers={}'# Expected: no servers, or all disabled# Actual: identical output — all servers still enabled# Workaround: disable per-server
codex mcp list -c 'mcp_servers.context7.enabled=false'# This works — context7 shows as disabled
Why this matters
Users running codex exec programmatically (e.g., from Claude Code or CI) want lightweight invocations without MCP server overhead. The intuitive override mcp_servers={} appears to work (no error) but silently loads all servers anyway, adding ~5K tokens of tool schemas and boot latency per call.
The per-server workaround (-c 'mcp_servers.X.enabled=false' repeated for each server) works but doesn't scale — you need to know every server name and add a -c flag for each one.
Suggested fix
Either:
Treat -c 'mcp_servers={}' as "replace the table" rather than "merge empty table" (breaking but correct)
Add a --disable-all-mcp flag or --no-mcp shorthand
Still no-ops on 0.149.1 (macOS arm64), and the per-server form no-ops too: with codex exec --json -c 'mcp_servers={ruflo={command="ak",args=["x","ruflo-mcp"]}}' — and likewise -c mcp_servers.<name>.enabled=false — the session still lists every config- and plugin-provided server when asked to enumerate them (7 servers in my case). Since plugins also mount servers regardless of config.toml, there is currently no per-invocation way to constrain the MCP roster for supervised exec runs. Either honoring the override or erroring loudly would unblock hermetic/CI exec use-cases.
Follow-up on my earlier note, checked on Codex CLI 0.157.1 (macOS arm64) in a fresh CODEX_HOME
with one stdio server: codex mcp list --json -c 'mcp_servers={}' still lists the server as "enabled": true, so an override cannot clear the table. -c mcp_servers.<name>.enabled=false
is honored by mcp list (it reports "enabled": false; checked with codex mcp list only, I have
not re-run the exec roster check from my earlier note), and that is what we now use, one
server at a time. Is clearing mcp_servers with an override meant to work, or is per-server
disabling the supported way?
Re-checked this on the latest Codex CLI in a fresh CODEX_HOME — the behavior is unchanged: -c 'mcp_servers={}' still silently no-ops instead of clearing the MCP server table. This is now confirmed across three releases (0.149.1, 0.157.1, 0.158.0) over about seven months, so it doesn't look like a transient regression — the TOML-merge behavior described in the original report still applies.
$ codex mcp list --json
[{"name":"testserver","enabled":true, ...}]
$ codex mcp list --json -c 'mcp_servers={}'# expected: no servers, or all disabled# actual: identical output, unchanged
[{"name":"testserver","enabled":true, ...}]
The per-server workaround still works as documented:
$ codex mcp list --json -c 'mcp_servers.testserver.enabled=false'
[{"name":"testserver","enabled":false, ...}]
I also checked for a dedicated suppression flag in case one had shipped since the last update — codex mcp --help and codex exec --help still only expose -c/--config and the generic --enable/--disable <FEATURE> toggles, nothing MCP-roster-specific.
Proposed fix approaches (unchanged from the original report, still the live options as far as I can tell)
Make -c 'mcp_servers={}' replace the table instead of merging an empty one into the existing config — this is the behavior most users reaching for this override actually expect, even though it's technically breaking for anyone relying on the current merge semantics.
Add an explicit --no-mcp / --disable-all-mcp flag that's unambiguous regardless of TOML merge semantics.
At minimum, document the merge behavior for table-valued overrides in codex exec --help / codex mcp --help so it fails predictably instead of silently.
Impact
For anyone using -c overrides in scripts, CI, or wrapper tooling, this is a silent-failure trap: the command exits 0 and produces no error, so there's nothing to catch in an automated pipeline — the only way to notice is to diff the server roster by hand. For projects like agentic-kit that shell out to codex exec for hermetic/lightweight subprocess runs, it means the per-invocation MCP suppression we'd want for CI has to fall back to enumerating and disabling every server by name, which is brittle against config changes and doesn't scale with plugin-mounted servers.
Would appreciate a maintainer read on whether "replace" semantics for mcp_servers={} is the intended direction, or whether per-server disabling is meant to remain the supported path going forward (as asked in the thread above) — happy to help verify a fix once there's a POC to test against. Thanks for looking at this!
Still reproduced on codex-cli 0.166.0 (npm @openai/codex latest on 2026-11-02), macOS 15.7.4 (24G517), Darwin 24.6.0 x86_64. Throwaway CODEX_HOME, not signed in, no model selected.
config.toml had two stdio servers, docs and other, each with command /bin/true.
codex mcp list --json and codex mcp list --json -c 'mcp_servers={}' both exit 0 and list both servers with "enabled": true. The file's headings are unchanged.
codex mcp list --json -c 'mcp_servers.docs.enabled=false' lists docs with "enabled": false and other with "enabled": true, so the per-server form works.
codex mcp --help and codex exec --help still have no all-off flag. codex exec --help documents --ignore-user-config ("Do not load $CODEX_HOME/config.toml"). codex mcp list --ignore-user-config exits 2 with unexpected argument '--ignore-user-config'. I did not run codex exec, so I have not checked whether that flag drops MCP servers. It also skips the whole user config, which is wider than an MCP switch.
Please make mcp_servers={} clear the table for one invocation, or add a single flag that disables every MCP server for one run.
Activity
v2.5.0: codex MCP-allowlist enforcement (F3-D.2 close) + supply-chain…
feat(runner): MCP detachment via --ignore-user-config (v2.1 PR 7/10) (#…
fix(codex): disable MCP servers in exec calls to avoid respawning pro…
pacphi commentedon Aug 26, 2026
Still no-ops on 0.149.1 (macOS arm64), and the per-server form no-ops too: with
codex exec --json -c 'mcp_servers={ruflo={command="ak",args=["x","ruflo-mcp"]}}'— and likewise-c mcp_servers.<name>.enabled=false— the session still lists every config- and plugin-provided server when asked to enumerate them (7 servers in my case). Since plugins also mount servers regardless of config.toml, there is currently no per-invocation way to constrain the MCP roster for supervisedexecruns. Either honoring the override or erroring loudly would unblock hermetic/CI exec use-cases.fix(codex): run governed Attempts as persistent sessions with a real …
feat(upstream-watch): confirm releases from the fixing change and go …
pacphi commentedon Sep 27, 2026
Follow-up on my earlier note, checked on Codex CLI 0.157.1 (macOS arm64) in a fresh
CODEX_HOMEwith one stdio server:
codex mcp list --json -c 'mcp_servers={}'still lists the server as"enabled": true, so an override cannot clear the table.-c mcp_servers.<name>.enabled=falseis honored by
mcp list(it reports"enabled": false; checked withcodex mcp listonly, I havenot re-run the
execroster check from my earlier note), and that is what we now use, oneserver at a time. Is clearing
mcp_serverswith an override meant to work, or is per-serverdisabling the supported way?
pacphi commentedon Sep 28, 2026
Re-checked this on the latest Codex CLI in a fresh
CODEX_HOME— the behavior is unchanged:-c 'mcp_servers={}'still silently no-ops instead of clearing the MCP server table. This is now confirmed across three releases (0.149.1, 0.157.1, 0.158.0) over about seven months, so it doesn't look like a transient regression — the TOML-merge behavior described in the original report still applies.System info
npm install -g @openai/codex@latest)Steps to reproduce (disposable
CODEX_HOME, no real config touched)config.toml:$ codex mcp list --json [{"name":"testserver","enabled":true, ...}] $ codex mcp list --json -c 'mcp_servers={}' # expected: no servers, or all disabled # actual: identical output, unchanged [{"name":"testserver","enabled":true, ...}]The per-server workaround still works as documented:
I also checked for a dedicated suppression flag in case one had shipped since the last update —
codex mcp --helpandcodex exec --helpstill only expose-c/--configand the generic--enable/--disable <FEATURE>toggles, nothing MCP-roster-specific.Proposed fix approaches (unchanged from the original report, still the live options as far as I can tell)
-c 'mcp_servers={}'replace the table instead of merging an empty one into the existing config — this is the behavior most users reaching for this override actually expect, even though it's technically breaking for anyone relying on the current merge semantics.--no-mcp/--disable-all-mcpflag that's unambiguous regardless of TOML merge semantics.codex exec --help/codex mcp --helpso it fails predictably instead of silently.Impact
For anyone using
-coverrides in scripts, CI, or wrapper tooling, this is a silent-failure trap: the command exits 0 and produces no error, so there's nothing to catch in an automated pipeline — the only way to notice is to diff the server roster by hand. For projects like agentic-kit that shell out tocodex execfor hermetic/lightweight subprocess runs, it means the per-invocation MCP suppression we'd want for CI has to fall back to enumerating and disabling every server by name, which is brittle against config changes and doesn't scale with plugin-mounted servers.Would appreciate a maintainer read on whether "replace" semantics for
mcp_servers={}is the intended direction, or whether per-server disabling is meant to remain the supported path going forward (as asked in the thread above) — happy to help verify a fix once there's a POC to test against. Thanks for looking at this!RandyNorthrup commentedon Nov 2, 2026
Still reproduced on codex-cli 0.166.0 (npm
@openai/codexlatest on 2026-11-02), macOS 15.7.4 (24G517), Darwin 24.6.0 x86_64. ThrowawayCODEX_HOME, not signed in, no model selected.config.tomlhad two stdio servers,docsandother, each with command/bin/true.codex mcp list --jsonandcodex mcp list --json -c 'mcp_servers={}'both exit 0 and list both servers with"enabled": true. The file's headings are unchanged.codex mcp list --json -c 'mcp_servers.docs.enabled=false'listsdocswith"enabled": falseandotherwith"enabled": true, so the per-server form works.codex mcp --helpandcodex exec --helpstill have no all-off flag.codex exec --helpdocuments--ignore-user-config("Do not load$CODEX_HOME/config.toml").codex mcp list --ignore-user-configexits 2 withunexpected argument '--ignore-user-config'. I did not runcodex exec, so I have not checked whether that flag drops MCP servers. It also skips the whole user config, which is wider than an MCP switch.Please make
mcp_servers={}clear the table for one invocation, or add a single flag that disables every MCP server for one run.