如何将 Cloudflare AI Gateway 远程 MCP 连接到 OpenAI Codex CLI

约 1 分钟即可把 Cloudflare 的远程 MCP 服务端接入 OpenAI Codex CLI。如需排查 OAuth / 401 问题,可先用 OAuth 2.1 调试器体检端点。

🛡️ Official✓ VerifiedStreamable HTTPOAuth 2.1🛡️ A+~265 tok4 tools
Streamable HTTPhttps://ai-gateway.mcp.cloudflare.com/mcp

Add to ~/.codex/config.toml — Codex reads remote HTTP servers from [mcp_servers.*] tables:

[mcp_servers.cloudflare-ai-gateway]
url = "https://ai-gateway.mcp.cloudflare.com/mcp"

接入步骤

  1. 编辑 TOML 配置 — 打开 ~/.codex/config.toml,加入 [mcp_servers.cloudflare-ai-gateway] 与 url = "https://ai-gateway.mcp.cloudflare.com/mcp"。
  2. 配置凭据 — 首次调用时客户端会打开 Cloudflare 的 OAuth 授权页面——点击允许后工具即可用。
  3. 验证 — 在 在线 Inspector 中粘贴 https://ai-gateway.mcp.cloudflare.com/mcp 并运行 initialize + tools/list 验证连通性。

🧰 工具预览(4)

ToolSafetyDescriptionParameters
list_gateways
~34 tok
🟢 ReadList AI gateways in your account.—
get_gateway_logs
~84 tok
🟢 ReadQuery request logs for a gateway with filters.gatewayId*: stringtimeRange: stringstatus: string
get_gateway_analytics
~73 tok
🟢 ReadGet usage metrics (requests, tokens, cost) for a gateway.gatewayId*: stringtimeRange: string
get_request_details
~54 tok
🟢 ReadGet full details of a single logged request.logId*: string

更多连接指南