Skip to main content
Glama
Cloudflare MCP Server

Cloudflare MCP Server

by ry-ops

✨ Ask things like

"List my zones." "Point staging.example.com at 203.0.113.10, proxied, then purge the cache." "Which DNS records point at the old server?" "Purge just /assets/app.css." "How much traffic and how many threats did example.com see this week?" "Store maintenance=true in the flags KV namespace."

Related MCP server: cloudflare-api-mcp

🧰 13 tools, and the permissions they need

Group

Tools

Token permission

Zones

list_zones, get_zone

Zone · Zone · Read

DNS

list_dns_records (filter by type, name or content), create_dns_record, update_dns_record, delete_dns_record

Zone · DNS · Edit

Workers KV

list_kv_namespaces, list_kv_keys, read_kv_value, write_kv_value, delete_kv_value

Account · Workers KV Storage · Edit, plus CLOUDFLARE_ACCOUNT_ID

Cache

purge_cache (everything, or specific files, tags or hosts)

Zone · Cache Purge · Purge

Analytics

get_zone_analytics (requests, bandwidth, threats, pageviews)

Zone · Analytics · Read

Seven tools only read. Six change things: creating, updating or deleting DNS records, purging the cache, and writing or deleting KV keys. A token without a permission can't use those tools, so grant only what you need.

🚀 Setup

1. Create an API token. In the Cloudflare dashboard, go to My Profile → API Tokens → Create Token. Start from the Edit zone DNS template, or build a custom token from the table above. Limit it to the zones you want the server to touch.

2. Find your Account ID (Workers KV only). It's on any zone's Overview page, in the right-hand column.

3. Install. You need Python 3.10+ and uv.

git clone https://github.com/ry-ops/cloudflare-mcp-server
cd cloudflare-mcp-server
uv sync

4. Connect Claude Desktop. Add this to claude_desktop_config.json: ~/Library/Application Support/Claude/ on macOS, or %APPDATA%\Claude\ on Windows.

{
  "mcpServers": {
    "cloudflare": {
      "command": "uv",
      "args": ["--directory", "/absolute/path/to/cloudflare-mcp-server", "run", "cloudflare-mcp-server"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "your_api_token",
        "CLOUDFLARE_ACCOUNT_ID": "your_account_id"
      }
    }
  }
}

The server reads only environment variables: CLOUDFLARE_API_TOKEN (required) and CLOUDFLARE_ACCOUNT_ID (for KV). Quit and reopen Claude Desktop to load it. There are more examples in EXAMPLES.md, and a short walkthrough in QUICKSTART.md.

🔒 Security

  • Scope the token to specific zones and only the permissions you need. The Edit zone DNS template plus Zone Read is enough for most DNS work.

  • Keep your MCP client's tool approval on. Deleting DNS records and purging cache take effect immediately.

  • Keep the token out of git. Put it in your client's env block, or in a secrets manager.

🤝 Agent-to-agent (A2A)

agent-card.json describes the server to other agents. It has five skills (zone management, DNS management, KV storage, cache management and analytics), and the minimum and recommended token permissions for each.

🩺 Troubleshooting

The token is wrong or is missing a permission for that tool. Check it against the table above, and that its zone resources include the zone you asked about.

Set CLOUDFLARE_ACCOUNT_ID, and give the token Account · Workers KV Storage · Edit.

Use an absolute path in --directory, run uv sync once in the project, check the JSON is valid, and quit Claude Desktop completely before reopening it.

🛠️ Development

uv sync
uv run cloudflare-mcp-server   # stdio server

All the code is in src/cloudflare_mcp_server/__init__.py. See CONTRIBUTING.md and CHANGELOG.md.

License

MIT. See LICENSE.


Available Tools

13 tools
create_dns_recordB

Create a new DNS record in a zone. Supports all DNS record types.

Inputs: zone_id (required), type (required), name (required), content (required), +4 more.

delete_dns_recordB

Delete a DNS record from a zone

Inputs: zone_id (required), record_id (required).

delete_kv_valueB

Delete a key from Workers KV storage

Inputs: namespace_id (required), key (required), account_id.

get_zoneA

Get detailed information about a specific zone by zone ID

Inputs: zone_id (required).

get_zone_analyticsB

Get analytics data for a zone including requests, bandwidth, threats, and pageviews.

Inputs: zone_id (required), since, until.

list_dns_recordsB

List DNS records for a zone. Can filter by type, name, content, etc.

Inputs: zone_id (required), type, name, content, +2 more.

list_kv_keysA

List all keys in a Workers KV namespace. Supports pagination and prefix filtering.

Inputs: namespace_id (required), account_id, prefix, limit, +1 more.

list_kv_namespacesB

List all Workers KV namespaces in the account. KV is Cloudflare's key-value storage.

Inputs: account_id, page, per_page.

list_zonesB

List all zones (domains) in the Cloudflare account. Returns zone details including ID, name, status, and nameservers.

Inputs: name, status, page, per_page.

purge_cacheB

Purge Cloudflare's cache for a zone. Can purge everything or specific files/tags/hosts.

Inputs: zone_id (required), purge_everything, files, tags, +1 more.

read_kv_valueB

Read a value from Workers KV storage by key. Returns the stored value.

Inputs: namespace_id (required), key (required), account_id.

update_dns_recordB

Update an existing DNS record. Can modify type, name, content, TTL, proxy status, etc.

Inputs: zone_id (required), record_id (required), type (required), name (required), +5 more.

write_kv_valueC

Write a key-value pair to Workers KV storage. Can store text or metadata.

Inputs: namespace_id (required), key (required), value (required), account_id, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 13 tools

    Disambiguation5/5

    Each tool targets a distinct operation within well-separated domains (DNS, KV, zones, cache, analytics). No two tools have overlapping purposes; an agent can easily distinguish them.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern (e.g., create_dns_record, list_kv_keys). There are no deviations or mixed conventions.

    Tool Count5/5

    With 13 tools covering DNS lifecycle, KV storage operations, zone queries, cache purging, and analytics, the count is well-scoped for a Cloudflare management server.

    Completeness4/5

    Core workflows are covered: DNS CRUD, KV operations (create/read/update/delete/list), zone listing/details, cache purge, and analytics. Minor gaps: no single DNS record retrieval (list can filter) and no zone creation, but overall coverage is strong.

    Maintenance

    ActivitySlowing
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers