MCP Cloudflare DNS

Cloudflare DNSのゾーン、レコード、キャッシュパージ、およびページルールを、MCP互換のAIアシスタントから管理できます。

ドキュメント

mcp-cloudflare-dns

Cloudflare DNS MCP server. Manage zones, DNS records, cache, and page rules from Claude, Cursor, Codex, or any MCP-compatible AI assistant.

# Install:  uvx mcp-cloudflare-dns

# Ask your AI:
"List all DNS records for example.com"
"Add a CNAME record pointing api.example.com to my-app.vercel.app"
"Purge the cache for https://example.com/products"
"What page rules are active on example.com?"

Start Here

You areStart withTime
Installing the serverQuickstart5 min
Creating a safe API tokenAPI token permissions5 min
Extending DNS/cache toolsdocs/architecture.md and cf/server.py15 min

Architecture

flowchart TD
    Client[MCP client] -->|stdio or SSE| Server[cf/server.py]
    Server --> Env[CF_API_TOKEN]
    Server --> Guard{Destructive allowed?}
    Server --> SDK[Cloudflare SDK]

    SDK --> Zones[Zones]
    SDK --> DNS[DNS records]
    SDK --> Cache[Cache purge]
    SDK --> Rules[Page rules]

    Guard -->|false| Block[Block delete/full purge]
    Guard -->|true| SDK
    Zones --> Result[MCP result]
    DNS --> Result
    Cache --> Result
    Rules --> Result
    Result --> Client

More detail lives in docs/architecture.md.


Primary Workflow

flowchart TD
    Ask([User asks DNS task]) --> Tool[Select MCP tool]
    Tool --> Validate{Token present?}
    Validate -->|no| ConfigError[Return config error]
    Validate -->|yes| Risk{Destructive action?}
    Risk -->|yes| Allow{CF_ALLOW_DESTRUCTIVE=true?}
    Risk -->|no| Call[Call Cloudflare API]
    Allow -->|no| Refuse[Refuse safely]
    Allow -->|yes| Call
    Call --> Return[Return zone or record result]

Why this one?

The official Cloudflare MCP covers Workers, KV, D1, and R2 — but has zero DNS tools. This server fills that gap.

FeatureThis serverOfficial CF MCP
DNS record CRUDYesNo
Zone listingYesNo
Cache purgeYesNo
Page rulesYesNo
Zone settingsYesNo
Workers/KV/D1/R2NoYes

They complement each other — use both.


Quickstart

1. Get a Cloudflare API tokendash.cloudflare.com/profile/api-tokens → Create Token → use "Edit zone DNS" template

2. Add to your MCP client config:

{
  "mcpServers": {
    "cloudflare-dns": {
      "command": "uvx",
      "args": ["mcp-cloudflare-dns"],
      "env": {
        "CF_API_TOKEN": "your-cloudflare-api-token"
      }
    }
  }
}

3. Restart your AI client. Done.


Available tools

ToolWhat it does
list_zonesAll zones on your account with status and nameservers
get_zoneDetails for a specific zone
get_zone_settingsSSL mode, security level, minification, HTTPS redirect, etc.
list_dns_recordsAll DNS records, filterable by type or name
get_dns_recordSingle record by ID
create_dns_recordAdd A, AAAA, CNAME, MX, TXT, NS, etc.
update_dns_recordEdit content, TTL, proxy status, or comment
delete_dns_recordRemove a record (requires CF_ALLOW_DESTRUCTIVE=true)
purge_cachePurge specific URLs or entire zone cache
list_page_rulesAll page rules with targets and actions

Environment variables

VariableRequiredDescription
CF_API_TOKENYesCloudflare API token (also accepts CLOUDFLARE_API_TOKEN)
CF_ALLOW_DESTRUCTIVENoSet to true to enable record deletion and full cache purge
MCP_TRANSPORTNoSet to sse for remote/VPS deployment (default: stdio)
MCP_HOSTNoSSE bind host (default: 127.0.0.1)
MCP_PORTNoSSE bind port (default: 3001)

API token permissions

Minimum required scopes for your token:

ResourcePermission
Zone — DNSEdit
Zone — ZoneRead
Zone — Cache PurgePurge
Zone — Page RulesEdit (if using page rules tools)

License

MIT

Reference