Connect
Cloudflare: connect a token, manage DNS and Workers
TL;DR
Cloudflare connects with an API token you create in Cloudflare. The token's own permissions decide what the agent can do: what it is not allowed to do is answered with the exact permission to add. Deleting a DNS record, deploying Worker code, removing a Worker route, purging the whole cache and TLS / security settings always wait for a person; members, API tokens, billing and deleting a zone are never reachable.
Connect
- 1In Cloudflare, open My Profile → API Tokens → Create Token. Use a template (Edit zone DNS) or a custom token, and give it only what the agent should have — for DNS: Zone · DNS · Edit; for Workers: Account · Workers Scripts · Edit; for reading traffic: Zone · Analytics · Read. Under Zone Resources you can limit it to some domains.
- 2On Integrations, press Connect with an API token on the Cloudflare card, paste the token and press Check and save. It is checked with Cloudflare before it is saved and stored encrypted.
- 3Each Cloudflare account the token reaches becomes a row, with what the token can and cannot do there. Several tokens (from teammates, or for other accounts) are fine; after editing a token in Cloudflare press Refresh accounts.
Which token permission unlocks what
| Area | Permission |
|---|---|
| Zones (domains) | Zone · Zone · Read |
| DNS records (read / change) | Zone · DNS · Read / Edit — the zone permission named just "DNS". DNS Settings, DNS Views and DNS Firewall are other, account-level permissions and do not reach records |
| Zone settings | Zone · Zone Settings · Read / Edit |
| Cache purge | Zone · Cache Purge · Purge |
| Rules (WAF, redirects, transforms, cache) | Zone · the matching Rules permission · Read / Edit |
| SSL/TLS certificates | Zone · SSL and Certificates · Read |
| Zone analytics | Zone · Analytics · Read |
| Workers scripts (read / deploy) | Account · Workers Scripts · Read / Edit |
| Workers routes | Zone · Workers Routes · Read / Edit |
| Pages, R2, KV, D1 | Account · Cloudflare Pages / Workers R2 Storage / Workers KV Storage / D1 · Read |
| Registered domains | Account · Domain Registration · Read |
cloudflare.get_capabilities re-checks the token at any time; the card lists the areas it cannot use.
Tools
| Tool | Kind | What it does |
|---|---|---|
| list_accounts / get_capabilities | Read | The accounts the token reaches; per area what it can do and the permission to add |
| list_zones / get_zone | Read | Zones: status, plan, name servers |
| list_dns_records / export_dns_records | Read | DNS records; the BIND zone file |
| get_zone_settings / list_rulesets / zone_analytics | Read | Settings; WAF / redirect / transform rules; requests, cache, threats, page views, visitors by day |
| list_workers / get_worker / list_worker_routes | Read | Workers, their settings and source, routes |
| list_pages_projects / list_r2_buckets / list_kv_namespaces / list_d1_databases / list_registrar_domains / get | Read | Pages, storage, databases, registered domains, any other read in the account |
| create_dns_record / update_dns_record | Write | Read first, shown before and after; taking a record off the proxy waits for a person |
| delete_dns_record | Write | Always waits for a person |
| set_zone_setting / purge_cache | Write | TLS / security settings and purging everything wait for a person |
| create_worker_route / delete_worker_route / deploy_worker | Write | Removing a route and deploying code always wait for a person |
| mutate | Write | Any other write in the account (DELETE, code, Pages deployments and registrar changes wait for a person) |
Over MCP and the REST API the names are cloudflare__<tool>; cloudflare__raw_request sends any Cloudflare API v4 request bound to the connected account (zone paths are proven to be the account's first; writes are queued for approval). Setup for Claude, Codex or Cursor: Cloudflare MCP server · Walkthroughs: an AI agent for Cloudflare DNS and Workers · limit an agent to some domains · What's new.
Keep the agent to some domains
- In Cloudflare: limit the token's Zone Resources to those domains — the strongest limit, it holds everywhere.
- In Agent Planners: a Forbidden Rule on Cloudflare with Domains & resources → Allow ONLY these and the domains (and, if you like, Who → API keys / connected apps) refuses every change outside them — including changes that name no domain. Reads stay open when the rule covers only Make changes and Delete.
Troubleshooting
| What you see | What it means | What to do |
|---|---|---|
| "The token does not have the permission …" | Cloudflare refused the call for this token | Edit the token in Cloudflare and add that permission, then Refresh accounts |
| "The zone … belongs to another Cloudflare account" | The token reaches several accounts | Pick that account's connection for the task |
| A Global API Key is refused | It carries every permission of your user | Create an API token instead |
| 401 after the token was rolled or deleted | It no longer works | Paste a new token on the card |
Frequently asked questions
- Does the agent get more access than the token?
- No. Every call uses your token; Cloudflare decides what it may do. We add our own approvals and refusals on top, never permissions.
- Can I connect several Cloudflare accounts?
- Yes — one token can reach several accounts (each becomes its own connection), and you can add more tokens.
- Does it work over MCP?
- Yes — cloudflare__<tool> and cloudflare__raw_request, with the same approvals; describe_tool shows each tool's policy. The Cloudflare MCP server guide at /resources/cloudflare-mcp-server has the setup and compares it with Cloudflare's own server.