Deploy to Cloudflare With an AI Agent
To deploy to Cloudflare with an AI agent, connect the official Cloudflare MCP with a scoped API token, then ask the agent to publish a Worker or Pages project. It deploys Workers from inline code or a bundle, sets KV/R2/D1 bindings and env vars, and rolls back to a previous Worker version. Because the same MCP also controls DNS and WAF, the agent can attach a domain and set an edge rule in the same conversation — the one hosting MCP that covers deploy, DNS, and edge security in a single install.
Before you start
You need a Cloudflare account, a Worker or Pages project, and an MCP-compatible client. The setup decision that matters is the token: scope it to exactly the permissions the agent needs, and never hand an agent the global API key.
Step by step
Create a scoped Cloudflare API token
In the Cloudflare dashboard, create an API token with only the permissions the agent needs: Workers Scripts:Edit to deploy Workers, Zone:Read and DNS:Edit for DNS, Account Analytics:Read for metrics. Avoid the global API key.
Connect the Cloudflare MCP
Add the official Cloudflare MCP to your client — remotely at mcp.cloudflare.com/mcp over OAuth, or locally via npx with CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID.
Deploy a Worker or Pages project
Ask the agent to publish a Worker from inline code or a bundle path, set its env vars and bindings (KV, R2, D1), and report the deployed URL.
Attach a domain and edge rules
Because the same MCP controls DNS and WAF, the agent can point a domain at the deployment and add an edge rule in the same conversation — no second tool.
Roll back if a deploy regresses
Ask the agent to publish a previous Worker version. Pair this with Cloudflare Change History so every agent-initiated change stays auditable.
Token permissions by task
| If the agent should… | Grant |
|---|---|
| Read analytics and zone config only | Account Analytics:Read, Zone:Read |
| Deploy Workers | + Workers Scripts:Edit |
| Edit DNS records | + DNS:Edit on the zone |
| Manage R2 / KV storage | + Workers KV / R2 permissions |
No confirmation layer on destructive ops
Frequently asked questions
How do I deploy to Cloudflare with an AI agent?
Connect the official Cloudflare MCP to your agent client with a scoped API token, then ask the agent to publish a Worker or Pages project. The Cloudflare MCP can deploy Workers from inline code or a bundle, set KV/R2/D1 bindings and env vars, and roll back to a previous Worker version — and because it also controls DNS and WAF, the agent can attach a domain and set an edge rule in the same install.
What API token permissions does the Cloudflare MCP need?
Only what the task requires. For read-only use: Account Analytics:Read and Zone:Read. To deploy Workers add Workers Scripts:Edit. For DNS changes add the DNS edit permission on the zone. Create a scoped token per use case rather than using the global API key, which grants every permission on the account.
Can the Cloudflare MCP roll back a deploy?
Yes. It can publish a previous Worker version, which is the rollback path for Workers. It can also set env vars and bindings and roll back if a deploy fails. Pair it with Cloudflare Change History so every agent-initiated change is auditable after the fact.
Is it safe to run the Cloudflare MCP against production DNS?
Only with a scoped token and approval enabled. DNS mistakes propagate quickly and can black-hole traffic, and the Cloudflare MCP runs destructive operations — delete Worker, purge zone — immediately, with no built-in confirmation layer. Scope the token, keep production changes behind a human approval step, and use Change History for audit.
Does the Cloudflare MCP also handle DNS and domains?
Yes — that is its distinguishing feature among hosting MCPs. The same install exposes DNS record CRUD, WAF rules, R2 and KV storage, and zone analytics alongside Worker deploys. For most agent-driven deploys that need a custom domain, it removes the need for a separate domains MCP.
Continue reading
Compare Cloudflare against the other hosting MCPs, or pair it with a domains MCP.
More guides
Ranked Guide
Best MCP Servers for Deploying Websites in 2026 (Ranked)
11 min read
Comparison
Vercel vs Netlify vs Cloudflare MCP: Which to Use (2026)
9 min read
Tutorial
Deploy to Vercel With an AI Agent (Vercel MCP, 2026)
7 min read
Strategy
Can an AI Agent Deploy to Production? (Safely, in 2026)
8 min read
Fundamentals
What Is MCP? A Plain-English Guide to Model Context Protocol
6 min read
Setup Guide
Best MCPs for Cursor in 2026 (Ranked + Setup)
8 min read
Setup Guide
Best MCPs for Claude Desktop in 2026 (Ranked + Setup)
9 min read
Setup Guide
Best MCPs for Claude Code in 2026 (Ranked + Setup)
8 min read
Setup Guide
Best MCPs for Windsurf in 2026 (Cascade-Ready Setup)
8 min read
Setup Guide
Best MCPs for VS Code in 2026 (Agent Mode + .vscode/mcp.json)
8 min read
Strategy
MCP Registry vs Curated Directory: Which Should You Use?
5 min read
Setup Guide
Best MCPs for ChatGPT: The Apps and Connectors Worth Installing
9 min read
Tutorial
How to Add an MCP Server to ChatGPT (Developer Mode + Apps Directory)
7 min read
Security
MCP Security: What to Know Before You Install
9 min read
Role Guide
Best MCPs for Marketers in 2026 (SEO, Email, Analytics)
8 min read
Strategy
Remote vs Local MCP Servers: When to Use Each
7 min read
Fundamentals
MCP vs Function Calling: What’s the Difference?
6 min read
Comparison
MCP Directories Compared: Top MCPs vs mcp.so vs PulseMCP vs mcp.directory
8 min read
Security
MCP Prompt Injection: How Tool-Calling Agents Get Hijacked
8 min read
Security
OAuth 2.1 for MCP: What the Spec Standardised and What You Need to Know
8 min read
Security
Sandboxing MCP Servers: Containers, Least Privilege, and Process Isolation
9 min read
Security
Rotating MCP Credentials: A Practical Guide for Leaks, Expiry, and Routine Hygiene
7 min read
Security
Least-Privilege Scoping for MCPs: How to Grant the Smallest Useful Permission
7 min read
Setup Guide
Best MCP Servers for Databases in 2026 (Ranked + Setup)
10 min read
Setup Guide
Best MCP Servers for Research in 2026 (Search, Scrape, Synthesize)
9 min read
Setup Guide
Best MCP Servers for Design-to-Code in 2026 (Figma → React)
9 min read
Setup Guide
Best MCP Servers for Domains in 2026 (Registrars + DNS)
9 min read
Tutorial
How to Buy a Domain From Claude (Cloudflare MCP, Step by Step)
6 min read
Tutorial
How to Search for Domains With an AI Agent (Cross-Registrar Workflow)
7 min read
Tutorial
How to Deploy a Website With an AI Agent (MCP Workflow)
8 min read