Skip to content

Codex: HTTP MCP servers get no configured headers #605

Open

Description

@alex-clickhouse

Problem

Codex sessions send no configured headers to external HTTP MCP servers. An HTTP MCP server that needs a header, for example Authorization, refuses the requests of a Codex session. The same server works in a Claude session.

Cause

CodexBackend._translate_mcp_server (nerve/agent/backends/codex/backend.py:649-660 on 9d4263b6) writes one --config override for each header, with the header name as a quoted part of a dotted key:

mcp_servers.<name>.env_http_headers."Authorization"="<ENV_VAR>"

Codex 0.164.0 (the pinned version) sends no header for this form. A test against an HTTP MCP probe showed:

  • a header written as a quoted key part (env_http_headers."X-Mcp-Quoted"=...) was missing;
  • a header written as a bare key part (env_http_headers.X-Mcp-Bare=...) was present.

_toml_str always quotes the name, so every configured header is lost.

Not affected

Fix

Write all headers of a server in one inline-table override, as #604 does for the endpoint provider:

mcp_servers.<name>.env_http_headers={"Authorization"="<ENV_VAR>", "X-Other"="<ENV_VAR_2>"}

Add a test that runs the real Codex binary against a capture server, or at minimum a unit test for the override string. Check the other --config overrides that put a quoted name in a dotted key.

How to reproduce

  1. Configure an HTTP MCP server with headers: {Authorization: "Bearer <token>"} and the Codex backend.
  2. Start a Codex session and call a tool of that server.
  3. The server receives no Authorization header.

Found while working on #604.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions