Skip to content

[Bug]: Codex per-thread mcp_servers override replaces MCP servers added with -c launch args #15828

Description

@illumin3dpb-ship-it

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Add a Codex provider instance whose launch args add a stdio MCP server, e.g. -c mcp_servers.extra.command="/path/to/server" (plus any args).
  2. Start a thread on that instance.
  3. Ask the agent to list its tools, or check which MCP servers Codex started.

Expected behavior

The thread gets T3's t3-code MCP server and the extra server from the instance's launch args, the same way a Claude instance with an extra --mcp-config gets both.

Actual behavior

Only t3-code is available. The extra server is never started.

codexThreadRuntimeParams (apps/server, Codex provider) sends:

config: {
  ...CODEX_THREAD_CONFIG,                       // { "tools.update_plan.enabled": true }
  mcp_servers: { "t3-code": { url, http_headers } },
}

Codex applies per-thread overrides after the process's -c flags, in the same session-flags layer. A single-segment key (mcp_servers) replaces the whole table those -c mcp_servers.extra.* flags built. Servers in ~/.codex/config.toml survive, because that is a lower layer and layers are deep-merged. This happens on every thread/start, thread/resume and thread/fork, so no launch-arg quoting can work around it.

Suggested fix (not tested)

Use a dotted key, as CODEX_THREAD_CONFIG already does for tools.update_plan.enabled:

"mcp_servers.t3-code": { url, http_headers },

That should set only T3's entry and keep other servers.

Impact

A Codex provider instance can't add its own MCP server through launch args, though Claude instances can with --mcp-config. The remaining options are editing the global ~/.codex/config.toml (which affects every Codex use on the machine) or wrapping the Codex binary to re-add the server.

Version or commit

T3 Code 0.0.46-nightly.20261003.2638 (Linux AppImage)

Environment

Fedora Linux, codex-cli 0.160.0, provider instance with custom launch args.

Workaround

A wrapper executable as the instance's binaryPath that re-adds the server, or a global ~/.codex/config.toml entry.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions