ChatGPT auth mode: Cloudflare challenge on connectors/directory/list blocks all MCP tool calls from CLI
Summary
When using codex with auth_mode=chatgpt (the default for ChatGPT subscription users), all MCP tool calls fail because the CLI cannot pass Cloudflare's anti-bot challenge on the connectors/directory/list endpoint.
Environment
- codex-cli 0.120.0 (installed via brew)
- macOS, M1 Air
- Auth:
auth_mode=chatgptin~/.codex/auth.json - MCP servers configured in
.codex/mcp_servers.json(local HTTP and stdio transports)
Reproduction
- Configure any MCP server in
.codex/mcp_servers.json - Ensure
auth_mode=chatgptin~/.codex/auth.json - Run
codex mcp list— showsAuth: Unsupportedfor all servers - Run any codex session that triggers MCP tool calls — all calls cancel with
"user cancelled MCP tool call"(misleading; no actual user cancel)
Root Cause
Under ChatGPT auth, codex routes MCP tool authorization through https://chatgpt.com/backend-api/connectors/directory/list. This endpoint is behind Cloudflare's anti-bot challenge requiring JavaScript execution and cookies. The CLI HTTP client cannot pass this challenge, so the call fails, tool authorization never completes, and every MCP tool call gets internally cancelled.
Evidence from ~/.codex/log/codex-tui.log:
- Cloudflare challenge HTML in response body:
<noscript>Enable JavaScript and cookies to continue</noscript> cf_chl_optand_cf_chl_tktokens present- Response is not valid JSON
Isolation
- Direct
codex exec PROBE(no MCP tool usage) works fine — API auth and chat path are healthy. - MCP servers respond correctly when probed directly via curl (tools/list in 150ms, tools/call in ~10s).
- Setting
tool_timeout_sec=60in mcp_servers config does not change behavior — cancel happens before timeout. auth_mode: chatgptwith fresh auth (last_refresh: 0.0 days) — auth itself is not stale.
Workaround
Switching to API key auth (OPENAI_API_KEY env var) bypasses the connectors directory entirely and MCP works. However, this bills against the API tier instead of the ChatGPT subscription, which is undesirable for subscribers.
Expected Behavior
ChatGPT auth mode should support MCP tool calls from the CLI, either by:
- Handling the Cloudflare challenge (cookie jar, retry with JS challenge tokens)
- Providing a flag to skip the connectors-directory routing for local MCP servers (no remote authorization needed)
- Documenting that ChatGPT auth mode is incompatible with MCP usage from CLI
2 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I can reproduce a related Cloudflare challenge behavior from a Chromebook/Crostini Linux environment, and the result appears to be User-Agent dependent.
Environment / matrix:
Diagnostic result from Chromebook / Crostini Linux on the home fiber connection:
cf-mitigated: challengepresentcf-mitigated: challengeabsentThe 401 response suggests that the request passed Cloudflare and reached the application layer, while the 403 response was a Cloudflare challenge.
This suggests that, at least in my environment, the block is not solely caused by TLS fingerprinting. HTTP-layer signals such as User-Agent appear to affect Cloudflare’s decision.
This may be relevant to ChatGPT auth mode / backend-api requests from the CLI, especially if some reqwest-based HTTP clients are using a default, missing, or non-browser-like User-Agent when calling
chatgpt.com/backend-api/*.