Skip to content
DevOps & Cloud InfrastructureJune 2026 · 13 min read

Cloudflare MCP Server Setup Guide: Edge DevOps & DNS Automation via AI

Manage global edge networks, DNS routing records, CDN cache invalidation, serverless Workers deployments, D1 databases, and KV storage directly from Claude Desktop and Cursor IDE using the Model Context Protocol.

1. Autonomous Edge Operations with Cloudflare MCP

Managing modern edge infrastructure and content delivery networks traditionally requires navigating complex cloud dashboards, configuring DNS records for domain verification, validating SSL certificate handshakes, and scheduling manual cache purges after deploying static frontend builds.

When developing cloud-native applications, context switching between code editors and the Cloudflare Dashboard slows down development velocity. By deploying the Cloudflare Model Context Protocol Server, developers can connect Claude Desktop and Cursor IDE directly to Cloudflare's global network.

Through standardized JSON-RPC 2.0 tool calls, the AI assistant can inspect active DNS zones, verify SSL/TLS settings, deploy serverless Workers functions, query distributed D1 SQLite databases, and invalidate CDN edge caches using conversational English.

2. Security Hardening: Creating Scoped Cloudflare API Tokens

Security must be prioritized when granting an AI assistant administrative control over cloud infrastructure. Cloudflare provides granular API tokens that limit access to specific zones and permissions. Never use your Global API Key, as it grants unrestricted administrative access to your entire account.

Follow these best practices to provision a secure, least-privilege token:

  1. Log into the Cloudflare API Tokens Dashboard.
  2. Click Create Token and select Create Custom Token.
  3. Assign a memorable token name such as Claude-Desktop-Edge-MCP.
  4. Configure minimum necessary permissions:
    • Zone → DNS → Edit (enables listing, adding, and updating DNS records).
    • Zone → Cache Purge → Purge (enables clearing CDN edge caches by path or tag).
    • Account → Workers Scripts → Edit (enables deploying and inspecting Workers).
    • Account → D1 → Edit (enables querying serverless D1 databases).
  5. Under Zone Resources, select “Include → Specific zone → yourdomain.com” to prevent the token from modifying other production domains in your account.
  6. Click Continue to summary → Create Token and copy the token secret string.

3. Multi-Client Installation Configurations

The Cloudflare MCP server can be installed via npx in both Claude Desktop and Cursor IDE:

Claude Desktop Config

claude_desktop_config.json
{
  "mcpServers": {
    "cloudflare": {
      "command": "npx",
      "args": ["-y", "@cloudflare/mcp-server-cloudflare"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "cf_api_token_xxxxxxxxxxxx",
        "CLOUDFLARE_ACCOUNT_ID": "a8f9481b62e49c..."
      }
    }
  }
}

Cursor IDE Config

.cursor/mcp.json
{
  "mcpServers": {
    "cloudflare": {
      "command": "npx",
      "args": ["-y", "@cloudflare/mcp-server-cloudflare"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "cf_api_token_xxxxxxxxxxxx",
        "CLOUDFLARE_ACCOUNT_ID": "a8f9481b62e49c..."
      }
    }
  }
}

Ensure that your CLOUDFLARE_ACCOUNT_ID is configured if you intend to query account-level resources such as Workers KV, Vectorize indices, or D1 databases.

4. Core DevOps Tool Capabilities & Prompts

Once installed, your AI assistant can execute edge administrative tasks directly:

Automated DNS Record Creation & Validation

Prompt: “Add a CNAME record for staging pointing to cname.vercel-dns.com with proxy enabled on mcpbridge.org.”

The MCP server queries zone records, validates that no conflicting A record exists, and dispatches the POST payload to Cloudflare DNS.

Targeted CDN Cache Invalidation

Prompt: “Purge Cloudflare cache for https://mcpbridge.org/sitemap.xml and all /docs/* paths.”

Instead of purging the entire cache (which causes backend origin stampedes), the MCP server triggers a targeted prefix purge.

Serverless D1 Database Queries

Prompt: “Inspect the schema of the submissions table in our D1 database and list the 5 most recent pending APIs.”

The AI runs read queries against your Cloudflare D1 edge database without leaving your IDE workspace.

5. Troubleshooting Cloudflare MCP Errors

When working with Cloudflare's REST API endpoints via Model Context Protocol, you may occasionally encounter error codes. Here is how to diagnose and resolve common failure cases:

Error CodeRoot CauseResolution
10000 Authentication ErrorInvalid or expired API tokenGenerate a new token at dash.cloudflare.com/profile/api-tokens
1001 Zone Not FoundToken lacks permission for requested domainAdd the specific zone to Zone Resources in token settings
81044 Record ExistsConflicting CNAME or A record already presentInspect existing DNS records before creating new subdomains