Codex + Cloudflare·续
Optimize my Worker to serve WebP images with responsive resizing using Cloudflare Images.
Add a cron trigger to my Worker that processes a job queue every hour.
Add a D1 database to my Worker and create a users table with full CRUD endpoints.
Configure Zero Trust access policies to protect my internal staging environment.
Tips
- The Cloudflare API MCP server uses Code Mode — Codex writes JavaScript against a typed API to reach any of 2,500+ endpoints in \~1,000 tokens.
Cloudflare MCP server repository
Installing additional MCP servers, and when to use Code Mode versus traditional MCP servers.
FAQ
<details>
<summary>Should I use Skills, the MCP server, a CLI, or all of them?
</summary>
All three. Skills load Cloudflare knowledge into every Codex session (when to use Durable Objects, how to structure a Workers project, etc.). The Cloudflare API MCP server handles platform operations (DNS, WAF, Zero Trust). Wrangler handles local dev, deploys, and migrations. The bundled <code>wrangler</code> Skill teaches Codex when to run CLI commands vs. call the MCP API. For tasks across the whole Cloudflare API, Codex can also use the <a href="https://developers.cloudflare.com/cf/">Cloudflare CLI</a>, <code>cf</code>.
</details>
<details>
<summary>Can Codex use the Cloudflare CLI?
</summary>
Yes. The <a href="https://developers.cloudflare.com/cf/">Cloudflare CLI</a>, <code>cf</code>, is in beta and covers the whole Cloudflare API and prints JSON output. Install it with <code>npm install -g cf</code>, sign in with <code>cf auth login</code>, and tell Codex to prefer it in <code>AGENTS.md</code>. Refer to <a href="https://developers.cloudflare.com/cf/agents/">Use cf with AI agents</a>.
</details>
<details>
<summary>How do I connect Codex to my Cloudflare account?
</summary>
The first time Codex calls a Cloudflare tool, you will be redirected to authorize via OAuth and choose permissions.
</details>
<details>
<summary>Is Codex open source?
</summary>
Yes. Codex is open source and available on GitHub at github.com/openai/codex.
</details>
Troubleshooting
<details>
<summary>MCP server not connecting
</summary>
Verify the server was added with <code>codex mcp add cloudflare --url https://mcp.cloudflare.com/mcp</code>. Run <code>codex mcp list</code> to confirm it appears, then use <code>/mcp</code> inside the Codex TUI to check its status.
</details>
<details>
<summary>Getting outdated information about Cloudflare products
</summary>
Point the agent directly at <a href="https://developers.cloudflare.com/llms.txt">developers.cloudflare.com/llms.txt</a> for a directory of every product, or <code>developers.cloudflare.com/<product>/llms.txt</code> for a product-specific index.
</details>
<details>
<summary>MCP server authentication fails
</summary>
Remove and re-add the MCP server. Complete the OAuth flow in your browser when prompted.
</details>
Build agents on Cloudflare
Cloudflare is not just a deploy target for agents, it is a full stack for building your own.
Agents SDK Stateful AI agents with state, scheduling, RPC, email, streaming chat — and the Code Mode SDK for token-efficient tool use.Learn more Build an MCP server Ship a remote MCP server on Workers with OAuth, durable state, and streamable HTTP transport.Learn more Workers AI Run open-source LLMs, embedding models, and image models at the edge. Use it as your agent's model provider.Learn more Worker Loader Load user-generated code into isolated Workers on demand. The secure sandbox behind Code Mode.Learn more
Other agents

Anthropic<h3>Claude Code</h3>Terminal-based coding agent that understands your codebase, runs commands, edits files, and manages git. Made by Anthropic.View guide 
Cursor<h3>Cursor</h3>AI-first IDE built on VS Code with multi-file Composer edits and background agents. Made by Cursor.View guide 
GitHub<h3>GitHub Copilot</h3>Editor extension and CLI with agent mode, workspace context, and native PR integration. Made by GitHub.View guide 
Anomaly<h3>OpenCode</h3>Open-source terminal agent with a rich TUI that works with 75+ LLMs. Made by Anomaly.View guide 
Mistral AI<h3>Vibe</h3>Coding agent for terminal, IDE, and cloud workflows that reads files, runs commands, writes code, and opens pull requests. Made by Mistral AI.View guide 
Cognition<h3>Devin</h3>A full IDE with an agent manager built in — the command center for managing all your agents in one place. Made by Cognition.View guide 
Microsoft<h3>Visual Studio Code</h3>Free, open-source code editor with native Model Context Protocol (MCP) client support and Copilot Chat integration. Made by Microsoft.View guide 
Command Code<h3>Command Code</h3>Command Code is one of the most used coding agents for open models. It automatically learns your coding taste and self-improves as you work.View guide 
LM Studio<h3>Bionic</h3>Powerful agent for coding and work. Natively local, with open models in the cloud. By LM Studio.View guide 
Factory<h3>Droid</h3>Model-agnostic coding agent that plans, edits files, runs commands, and automates CI, from the terminal, desktop app, or cloud. Made by Factory.View guide
Was this helpful?
YesNo
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/agent-setup/codex/#page","headline":"Codex + Cloudflare","description":"OpenAI coding agent available as a terminal CLI and desktop app. It reads and writes files, runs commands, and browses the web in a sandbox.","url":"https://developers.cloudflare.com/agent-setup/codex/","inLanguage":"en","image":"https://developers.cloudflare.com/agent-setup/codex/og.png?v=a071c5162a14c963","dateModified":"2026-10-14","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Use Command Code with Cloudflare projects, Cloudflare Skills, the Cloudflare MCP servers, and Wrangler from your terminal. title: Command Code + Cloudflare image: https://developers.cloudflare.com/agent-setup/command-code/og.png?v=c491d96cb16733a4
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/agent-setup/llms.txt
Use this file to discover all available pages before exploring further.


Command Code
