codex - 💡(How to fix) Fix ChatGPT auth mode: Cloudflare challenge on connectors/directory/list blocks all MCP tool calls from CLI [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#21346Fetched 2026-05-07 03:41:30
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

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.

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_opt and _cf_chl_tk tokens present
  • Response is not valid JSON

Fix Action

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.

RAW_BUFFERClick to expand / collapse

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=chatgpt in ~/.codex/auth.json
  • MCP servers configured in .codex/mcp_servers.json (local HTTP and stdio transports)

Reproduction

  1. Configure any MCP server in .codex/mcp_servers.json
  2. Ensure auth_mode=chatgpt in ~/.codex/auth.json
  3. Run codex mcp list — shows Auth: Unsupported for all servers
  4. 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_opt and _cf_chl_tk tokens 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=60 in mcp_servers config does not change behavior — cancel happens before timeout.
  • auth_mode: chatgpt with 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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING