All docs
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

  1. 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.
  2. 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.
  3. 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

AreaPermission
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 settingsZone · Zone Settings · Read / Edit
Cache purgeZone · Cache Purge · Purge
Rules (WAF, redirects, transforms, cache)Zone · the matching Rules permission · Read / Edit
SSL/TLS certificatesZone · SSL and Certificates · Read
Zone analyticsZone · Analytics · Read
Workers scripts (read / deploy)Account · Workers Scripts · Read / Edit
Workers routesZone · Workers Routes · Read / Edit
Pages, R2, KV, D1Account · Cloudflare Pages / Workers R2 Storage / Workers KV Storage / D1 · Read
Registered domainsAccount · Domain Registration · Read
cloudflare.get_capabilities re-checks the token at any time; the card lists the areas it cannot use.

Tools

ToolKindWhat it does
list_accounts / get_capabilitiesReadThe accounts the token reaches; per area what it can do and the permission to add
list_zones / get_zoneReadZones: status, plan, name servers
list_dns_records / export_dns_recordsReadDNS records; the BIND zone file
get_zone_settings / list_rulesets / zone_analyticsReadSettings; WAF / redirect / transform rules; requests, cache, threats, page views, visitors by day
list_workers / get_worker / list_worker_routesReadWorkers, their settings and source, routes
list_pages_projects / list_r2_buckets / list_kv_namespaces / list_d1_databases / list_registrar_domains / getReadPages, storage, databases, registered domains, any other read in the account
create_dns_record / update_dns_recordWriteRead first, shown before and after; taking a record off the proxy waits for a person
delete_dns_recordWriteAlways waits for a person
set_zone_setting / purge_cacheWriteTLS / security settings and purging everything wait for a person
create_worker_route / delete_worker_route / deploy_workerWriteRemoving a route and deploying code always wait for a person
mutateWriteAny 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 seeWhat it meansWhat to do
"The token does not have the permission …"Cloudflare refused the call for this tokenEdit the token in Cloudflare and add that permission, then Refresh accounts
"The zone … belongs to another Cloudflare account"The token reaches several accountsPick that account's connection for the task
A Global API Key is refusedIt carries every permission of your userCreate an API token instead
401 after the token was rolled or deletedIt no longer worksPaste 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.

Related