Empty [mcp_servers] in agent role files does not clear inherited MCP servers

Open 💬 1 comment Opened Apr 3, 2026 by Auties00

What version of Codex CLI is running?

codex-cli 0.118.0

What subscription do you have?

Codex Pro

Which model were you using?

gpt-5.4

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What terminal emulator and version are you using (if applicable)?

Winddows Terminal (Command Line)

What issue are you seeing?

When declaring an agent in .codex/agents, specifying an empty [mcp_servers] table to clear inherited MCP servers has no effect: the servers from the parent context are still inherited.

# .codex/agents/noop_no_mcp.toml

name = "noop_no_mcp"
description = "Agent with no MCP servers"
developer_instructions = "You are a minimal agent."

[mcp_servers]
# Intended to clear inherited MCP servers, but they are still inherited

What steps can reproduce the bug?

  1. Configure one or more MCP servers in your user or project config.toml:
[mcp_servers.my-tool]
command = "python"
args = ["my-script.py"]
  1. Create an agent role file at .codex/agents/noop.toml with an empty [mcp_servers] section (as shown above).
  2. Spawn the agent: the inherited MCP servers are still present despite the empty override.

What is the expected behavior?

An empty [mcp_servers] table in a higher-precedence config layer should clear all inherited MCP servers, giving three clear semantics:

  • [mcp_servers] with no entries -> clears all inherited servers
  • [mcp_servers] with some entries -> overrides parent servers
  • Omitting [mcp_servers] entirely -> inherits from parent (existing behavior)

Additional information

I've already fixed the issue locally, but I noticed PRs cannot be opened without approval. Let me know if I can open one

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗