Repository navigation
Open
Labels
CLIIssues related to the Codex CLIbugSomething isn't workingexecIssues related to the `codex exec` subcommandmcpIssues related to the use of model context protocol (MCP) serverswindows-osIssues related to Codex on Windows systems
Description
Environment
- codex-cli version:
codex-cli 0.147.0-alpha.6.6(alpha channel) - OS: Windows 11 (native, x64)
- MCP server type: streamable HTTP (ASP.NET / IIS), responses encoded as SSE (
Content-Type: text/event-stream), stateless (noMcp-Session-Idheader returned) - Server side verified healthy: direct
curlinitialize/notifications/initialized/tools/listreturns 200/202/200 with the full tool list
config.toml (minimal repro)
[mcp_servers.example-erp]
enabled = true
url = "http://<mcp-host>/mcp"
[mcp_servers.example-erp.http_headers]
Authorization = "Bearer <token>"Steps to reproduce
- Configure a streamable HTTP MCP server as above (server returns tools via
tools/list). - Run:
codex exec --json --skip-git-repo-check --sandbox workspace-write -C <temp-dir> -m <model> -c notify=[] "Call the MCP tool <tool> and return the result." - Observe the agent's available tool set.
Expected behavior
Tools returned by tools/list are registered and callable by the model — as in Codex desktop (ChatGPT app) with the same config, where the same tools are visible and usable.
Actual behavior
The model reports the tools do not exist (e.g. "no erp_describe / erp_query tool in this session"). The MCP connection itself works fine:
- codex sends
initialize→notifications/initialized→tools/listand receives 200 with all tools (verified by a local reverse proxy capturing the actual HTTP exchange). list_mcp_resourceswithserver=<id>reaches the server and returns-32601: Method 'resources/list' is not available— proving the connection and authentication are working (a wrong token would have produced 401).- The model's tool set only contains built-in tools (
shell_command,list_mcp_resources, ...); no tools fromtools/listappear.
Config variants tried (none changed the behavior)
http_headersstaticAuthorization(original)bearer_token_env_varinstead of the static header- explicit
enabled_toolsallowlist listing all server tools -c features.tool_call_mcp_elicitation=falseapproval_policy = { granular = { sandbox_approval=true, rules=true, mcp_elicitations=true, request_permissions=true, skill_approval=true } }--sandbox read-onlyvsworkspace-write; with/without-Cand--skip-git-repo-check; temp dir vs trusted project dir- direct connection vs local reverse proxy
Diagnostics already performed
codex mcp list/codex mcp get <id>/codex doctor: server shown as enabled, transportstreamable_http, auth "Bearer token", doctor reports MCP servers healthy (0 disabled, 0 failed).RUST_LOG=codex_core=trace,reqwest=trace: shows the HTTP connection to the MCP host and the completed handshake, but no tool registration from thetools/listresponse.- Feature flags in this build:
tool_call_mcp_elicitation= stable/true,mcp_2026_07_28= under development/false,non_prefixed_mcp_tool_names= under development/false.
Impact
This blocks headless/non-interactive codex exec usage with streamable HTTP MCP servers (agent cannot use any MCP tool), while interactive clients (desktop) work with the identical configuration.
Version
codex --version → codex-cli 0.147.0-alpha.6.6
Metadata
Metadata
Assignees
Labels
CLIIssues related to the Codex CLIbugSomething isn't workingexecIssues related to the `codex exec` subcommandmcpIssues related to the use of model context protocol (MCP) serverswindows-osIssues related to Codex on Windows systems
Activity
github-actions commentedon Aug 15, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Ben-Home commentedon Aug 15, 2026
The server-side curl checks are the right starting point, and the "SSE responses from a stateless server" detail is probably the crux. On streamable HTTP, the spec allows a server to answer a POST with either plain JSON or an SSE stream, and a stateless ASP.NET/IIS endpoint that always emits Content-Type: text/event-stream for tools/list will break clients that parse the POST response body as JSON. They read the event envelope (or an empty JSON body) and register zero tools, so the model never sees mcp__ tools even though /mcp-level connectivity and the server itself are healthy.
Things to verify in order:
Response shape per request. Run curl against tools/list specifically (not just initialize) and check Content-Type. If it returns text/event-stream with data: lines, try the same endpoint and confirm whether the client tolerates SSE framing on POST. The spec's GET stream and POST responses have different framing expectations; servers that conflate them produce exactly this "server verified healthy, client injects nothing" symptom.
Session-id handling. Stateless (no Mcp-Session-Id) is legal, but some clients treat a missing session header as a protocol error and tear down the initialized session before tools/list. Confirm the server does not emit a session id on initialize but require it on later requests, which would also silently drop the tool list.
Client-side visibility. Run codex with MCP logging enabled and look for the tools/list response as parsed by the client — if the log shows the raw SSE envelope or a parse error, the framing mismatch is confirmed and the fix belongs on the server (return application/json for POST tools/list; reserve SSE for the GET stream).
This mirrors what we hit wiring streamable-HTTP servers into the gateway at corpusiq.io: framing consistency between POST-JSON and GET-SSE was the single highest-yield fix for "server says connected, client sees no tools" reports across different client implementations.
TarjinderSingh commentedon Aug 15, 2026
I have a possibly related macOS A/B reproduction, with one important difference: the MCP tool is injected and the call starts, but execution then fails with an empty error.
Error calling tool '<tool>':and no error textAn authenticated MCP initialize also succeeds independently. This suggests a version-specific failure after tool registration rather than the tool-injection failure described in this issue.
I filed the complete sanitized reproduction at: #38794
jdcodes1 commentedon Aug 17, 2026
Traced this on
main@ 1f41cc5, and there's a mechanism that fits every one of your observations — including why yourRUST_LOGcapture showed a healthy handshake but no registration.Optional MCP servers get a 1-second startup grace before being silently omitted from the model's tool set. When the turn builds its tool binding, any non-required server whose startup hasn't completed is given
OPTIONAL_MCP_STARTUP_GRACE— hardcoded to 1s — and then dropped from the catalog with only a trace-level log:codex/codex-rs/codex-mcp/src/connection_manager/tool_catalog.rs
Lines 175 to 225 in 1f41cc5
(
const OPTIONAL_MCP_STARTUP_GRACE: Duration = Duration::from_secs(1)at #L35; the omission logs"omitting pending optional MCP server".) User-configured servers are "optional" here —required_serversis a separate turn-level concept — so nothing forces the wait.Why
codex execfails while Desktop works with identical config: exec is one-shot — its only sampling request snapshots the binding immediately at session start, so a streamable-HTTP server doing initialize → initialized → tools/list over a real network on a cold start loses the 1-second race essentially every time. The wire exchange still completes (your reverse-proxy capture) — just after the binding was already taken, and exec never builds another one. Desktop sessions are long-lived: by the second turn (or the next MCP refresh) startup is complete and the tools appear.list_mcp_resourcesworking is also consistent: that goes through the live connection rather than the pre-snapshotted tool catalog.Why your trace didn't show it: the omission message is logged under the
codex_mcptarget at TRACE level; your filterRUST_LOG=codex_core=trace,reqwest=tracedoesn't include it. A directly actionable next step that would confirm this end-to-end on your setup:If the line appears, this is confirmed. (One alternative worth ruling out while you're in there: with a stateless server that returns no
Mcp-Session-Id, ifstartup_completenever flips — e.g. the client blocks establishing the follow-up SSE stream — you'd see the same omission on every snapshot; the trace will show whether startup eventually completes or hangs.)Fix outline:
codex exec(single-turn, cold cache), treat configured MCP servers as required for the first binding — or scale the grace with an explicit flag/config (--wait-for-mcp/mcp_startup_timeout) instead of a hardcoded 1s that no headless network server can reliably meet.example-erpwas still starting and was excluded from this turn") rather than a trace line — your report documents several hours of elimination work that a single warning would have prevented.-Ctemp dirs defeat it, which is exactly the headless CI/automation profile this issue is about.aldi949 commentedon Sep 23, 2026
@JCY2023 hey — I'm looking into cases where MCP appears correctly configured but the actual tool set reaching the model is different.
Did you eventually find a workaround for this, and is it still reproducible?
Also, was figuring out where the tools disappeared actually time-consuming? I'm trying to understand whether there's a broader observability/debugging problem here rather than just individual MCP bugs.
docker: containerized harness verification workspace
docker(codex): PTY-driven interactive verification path
docker(codex): PTY-driven interactive verification path
docs: mark Codex CLI live-verified (interactive TUI in Docker)