bug: -c 'mcp_servers={}' silently no-ops instead of clearing MCP servers
Open 💬 0 comments Opened Mar 27, 2026 by chriscoey
Summary
-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-mcpflag or--no-mcpshorthand - Document the limitation in
codex exec --help
Environment
- codex v0.117.0-alpha.24
- macOS 15.4