Repository navigation
Description
What version of Codex CLI is running?
codex-cli 0.125.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.5
What platform is your computer?
Linux 6.17.0-22-generic x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
WezTerm 20260331-040028-577474d8
What issue are you seeing?
When a parent session has MCP servers configured (either globally in ~/.codex/config.toml or at project level), all spawned subagents
inherit them. There is currently no documented way for a custom subagent to disable or override this inheritance.
Our environment has 6 subagents, but only 1-2 of them actually need MCP access. The remaining agents (report generation, environment
maintenance, diagram building, read-only audit) work exclusively with local files. Despite this, every subagent spawn waits for all MCP
servers to start — including built-in ones like codex_apps — adding ~20-30 seconds of overhead per spawn with no benefit.
What we tried:
- Setting mcp_servers = {} in the agent TOML → inherited servers still load
- The subagents documentation states that mcp_servers "inherit from the parent session when you omit them" but provides no syntax for
explicitly clearing or restricting inheritance
Requested feature:
- Allow mcp_servers = {} (or similar) in agent TOML to explicitly disable all inherited MCP servers for that agent
- Alternatively, support an allowlist/blocklist model: mcp_servers.inherit = false or mcp_servers.exclude = ["codex_apps", "proceset"]
- Document the inheritance override behavior either way
Impact:
- Faster subagent startup (skip unnecessary MCP connections)
- Better security posture (read-only audit agent shouldn't have write MCP tools)
- Reduced resource consumption for agents that don't need external tool access
Environment: Codex CLI, 6 custom subagents, 1 stdio MCP server (69 tools), codex_apps built-in
What steps can reproduce the bug?
- Create ~/.codex/config.toml with a global MCP server (or have codex_apps built-in)
- Create a custom subagent in .codex/agents/sesrep.toml that does NOT need MCP access
- Add mcp_servers = {} to the agent TOML, expecting it to disable inherited servers
- Spawn the subagent: "Use sesrep. Generate a report."
- Observe: the subagent still shows "starting mcp servers: (1/2): codex_apps" and waits for all inherited MCP servers to initialize,
despite the explicit empty override - The inherited MCP tools are also visible to the subagent, even though its contract does not require them
What is the expected behavior?
When a custom subagent explicitly sets mcp_servers = {} in its TOML config, it should spawn without loading any MCP servers — neither
inherited from the parent session nor built-in ones like codex_apps.
Expected startup output: no "starting mcp servers" step.
Expected tool access: only Codex built-in tools (file read/write, shell), no MCP tools.
Expected startup time: near-instant, without 20-30 sec MCP initialization overhead.
Additional information
Documentation reference: https://developers.openai.com/codex/subagents states that mcp_servers "inherit from the parent session when you omit them" but provides no syntax or guidance for explicitly clearing or restricting this inheritance.
This is not just a performance issue — it also affects security posture. Our read-only audit agent (sandbox_mode = "read-only") still
inherits write-capable MCP tools like execute_graphql and create_script, which contradicts the principle of least privilege.
Workaround attempted: setting approval_mode = "approve" on dangerous tools at the parent level, but this is defense-in-depth, not proper
scoping.
Activity
rirze commentedon Apr 30, 2026
This would be a great feature, speeding up subagent speed by a magnitude.
garyfpga commentedon May 2, 2026
yes please add this feature
soundslikeinfo commentedon May 10, 2026
I need this.
insilications commentedon Jun 15, 2026
Need this as well...
Necmttn commentedon Jun 21, 2026
The clean contract is a real three-state distinction:
mcp_serversmeans inherit parent;mcp_servers.inherit = falsemeans inherit none;I would also record a per-child capability manifest at spawn: inherited servers, enabled servers, suppressed servers, and startup latency. That gives users an audit trail for why a subagent had access to a tool and shows the time saved by not starting servers that the child cannot use.
Generated with ax.
AndrewDongminYoo commentedon Sep 7, 2026
Reproduced on Codex CLI 0.153.4, macOS arm64, with an explicitly enabled multi-agent v2 session on 2026-09-07.
This includes a successful call to the supposedly disabled tool, not just its appearance in the tool catalog.
Reproduction and observed result
node_replenabled in the parent configuration.explorerrole:codex exec --enable multi_agent_v2.node_repl.jsin the parent withnodeRepl.write("PARENT_MCP_SCOPE_PROBE")to establish that the parent transport works.agent_type = "explorer"withfork_turns = "none"and have the child make one ordinarynode_repl.jscall withnodeRepl.write("CHILD_MCP_SCOPE_PROBE").Both calls returned their markers with
isError: false.The native child rollout identifies the role as
explorerand the multi-agent version asv2, and records the completed MCP call.Neither call interacted with browser or device UI.
The role override was removed after verification because it did not enforce the intended restriction.
Source-level explanation
At the official
rust-v0.153.4commit,3d2ee51ca2d5db578f328aa75e20aa22c0197c9a:AgentRoleOverrideshas no MCP or per-plugin server policy field.apply_role_to_config_innerparses the role, then rebuilds the applied layer from the selected override fields.apply_role_cannot_expand_parent_authorityexplicitly checks that parent MCP settings remain unchanged and that the applied role layer omitsmcp_servers.The authority safeguard is valuable, but this path also excludes restrictions that only reduce the parent's grant.
Loading the same TOML as top-level CLI overrides does not test this role-application path.
Focused code proposal
I support the three-state semantics in the earlier comment.
A dedicated optional field such as
mcp_allowcould express them without treating policy keys as server definitions:The field name is illustrative and is not supported configuration today.
This also aligns with the allowlist discussion in #38353 and its existing fork draft.
For example, the set-resolution step can stay small:
This is a standalone resolver sketch, not an integrated Codex patch.
Its five standalone Rust tests passed for omitted, empty, subset, unknown-ID, and role-cannot-expand-spawn-grant cases.
A negative control that treated an empty list as inheritance made the empty-policy test fail.
Integration would need to:
A per-child manifest could record the requested policy, inherited/enabled/suppressed server IDs, cache status, and observed startup latency, without credentials.
Startup time saved should be reported only when a comparison baseline was measured.
This proposal leaves connection pooling and automatic process teardown as separate work.
It is submitted here as reproduction evidence and a code-design suggestion under the current contribution policy.
aldi949 commentedon Sep 23, 2026
@GlebGlebovAKAJJ hey — I've found several independent reports around the same underlying problem: controlling what MCP capabilities actually reach each subagent.
Do you still have to work around this today?
And one thing I'm really curious about: would you actually use external tooling to inspect/control agent MCP scope, or is this only useful to you if Codex implements it natively?
amitp-cerebras commentedon Oct 15, 2026
Joining the crowd - this is a needed feature.
QuentinBisson commentedon Oct 27, 2026
A proposal that stays inside the rule #39299 set: a role may only reduce what it inherits.
Today
apply_role_to_config_inner(core/src/agent/role.rs) already keeps two kinds of reduction from a role file: disabling features (shell, apps, plugins, memory, request permissions) and disabling skills (skills.config.retain(|skill| !skill.enabled)). Everything undermcp_serversis dropped. MCP could follow the same filter:[mcp_servers.<name>] enabled = falseturns off an inherited server for that role.enabled_tools/disabled_toolson an inherited server narrow it further; they only intersect with the parent's setting, never widen it.This also covers #40130's "readonly agent" case for MCP, without bringing back role-defined servers.
Our use case: we compile agent definitions into Codex roles. A parent holds the union of its subagents' MCP servers, and each role should see only its own. Without a reduction, every role sees every server.
Happy to send a PR along these lines if the approach is acceptable.
ntsanderc commentedon Nov 11, 2026
Another data point, from Codex Desktop on macOS arm64 (app-server
codex-cli 0.167.0-alpha.3.2,multi_agent = true, v2 subagents). It extends the source-level explanation above to the plugin-scoped keys.Setup
~/.codex/agents/*.tomlthat need no MCP access carry:Observed
psconfirmed the sets were running.logs_2.sqlite) shows the child'ssession_init.mcp_manager_init->mcp.runtime.refresh:new{server_name=...}completing MCP handshakes for those servers under the parent'sspawn_agentspan.[plugins."<id>"] enabled = falsenor[plugins."<id>".mcp_servers.<name>] enabled = falseis applied to a spawned child's MCP runtime. This matchesAgentRoleOverrideshaving no MCP or per-plugin server field.[mcp_servers.<name>] enabled = falsewith no transport makes the whole role fail to load:failed to deserialize agent role file ...: invalid transport, thenunknown agent_type. Roles therefore cannot express a pure "disable this inherited server" entry.Why it is hard to reproduce
In a fresh private
codex app-server(same binary and same flags as Desktop,fork_turnsall or none, resumed parent, Full Access or read-only), the child reused the parent's healthy servers. It restarted only the servers that had failed. The full per-child set appeared only on some spawns in a long-lived Desktop app-server. Two spawns under the same parent in the same second got different outcomes. A short repro can therefore look clean even though the role keys are ignored.Impact
One Desktop app-server running for about 28 hours held 311 child processes (about 11.2 GB) across 17 MCP sets. All of the subagents that caused it used roles intended to need no MCP access, or only 3 servers. Combined with completed subagents keeping their runtimes (#38247), memory use grows with each subagent spawned.
+1 for a subtractive, role-applied MCP grant. The
mcp_allowsemantics proposed above would cover this case. Plugin-scoped server IDs should be in scope for that grant.