MCP Library updated 14 min read

Cloudflare MCP Server: Manage Edge Infra with AI

Manage Cloudflare infrastructure using AI. Control DNS, Workers, R2 storage, and edge settings with natural language commands.

Rajesh Praharaj

· Updated

Contents 13 sections
  1. TL;DR - Cloudflare MCP Quick Start
  2. Prerequisites
  3. Installation & Configuration
  4. Available Tools
  5. Practical Workflows
  6. Example Prompts
  7. Multiple Accounts/Zones
  8. Security Best Practices
  9. Combining with Other MCPs
  10. Troubleshooting
  11. Related MCP Servers
  12. Summary
  13. Frequently Asked Questions

TL;DR - Cloudflare MCP Quick Start

Manage your edge infrastructure with AI - Control DNS, Workers, R2, D1, KV, and WAF settings using the official cloudflare/mcp-server-cloudflare repository and Cloudflare’s managed Remote MCP servers documented at Cloudflare Agents & MCP. When designing distributed edge architectures with our AI System Design Generator and frontier models ranked on our LLM Benchmarks, Cloudflare’s modular remote MCP servers reduce tool context overhead by 70% (from 8,500+ tokens for a monolithic server down to 950 to 1,800 tokens per specialized server) and achieve sub-50ms global edge cold starts.

2026 Cloudflare Remote MCP & Code Mode Architecture Summary
  • 13+ Modular Remote MCP Servers: Cloudflare provides specialized remote OAuth 2.1 endpoints (observability.mcp.cloudflare.com/mcp, bindings.mcp.cloudflare.com/mcp, radar.mcp.cloudflare.com/mcp, docs.mcp.cloudflare.com/mcp) via @cloudflare/mcp-server-cloudflare and McpAgent on Durable Objects.
  • Code Mode Token Compression: Cloudflare’s Code Mode compiles multi-step tool calls into typed TypeScript V8 isolate executions, reducing LLM token consumption by 99.9% across Cloudflare’s 2,500+ API endpoints.
  • Rate Limits & Quotas: Cloudflare’s core REST API enforces 1,200 requests per 5 minutes per user/token alongside zero-egress R2 storage pricing.

Quick Setup:

{
  "mcpServers": {
    "cloudflare": {
      "command": "npx",
      "args": ["-y", "mcp-server-cloudflare"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "your-api-token",
        "CLOUDFLARE_ACCOUNT_ID": "your-account-id"
      }
    }
  }
}

What you can do:

  • DNS: List, create, and manage DNS records
  • Workers: Deploy and manage edge functions
  • R2: Manage object storage
  • Security: Firewall rules and settings
  • Analytics: Traffic and performance insights

Example conversation:

You: List all DNS records for example.com

Claude: Here are the DNS records for example.com:

        | Type  | Name        | Content          | TTL  | Proxied |
        |-------|-------------|------------------|------|---------|
        | A     | @           | 192.0.2.1        | Auto | ✅      |
        | A     | www         | 192.0.2.1        | Auto | ✅      |
        | MX    | @           | mail.example.com | 3600 | ❌      |
        | TXT   | @           | "v=spf1..."      | Auto | ❌      |
        | CNAME | api         | api-lb.cf.com    | Auto | ✅      |

Get your API token at dash.cloudflare.com/profile/api-tokens

Remote MCP: Cloudflare hosts MCP servers on its global edge - no local hosting required! For an introduction to MCP, see the MCP Introduction guide.


Prerequisites

1. Cloudflare Account

Free or paid Cloudflare account with at least one domain.

2. API Token

Create a scoped API token:

  1. Go to Cloudflare Dashboard
  2. Click your profile → API Tokens
  3. Click Create Token
  4. Use a template or create custom:

For Read-Only Access:

  • Zone: Read
  • DNS: Read
  • Analytics: Read

For Full Management:

  • Zone: Edit
  • DNS: Edit
  • Worker Scripts: Edit
  • R2: Edit
  1. Set zone restrictions if needed
  2. Create and copy the token

3. Account ID

Find your Account ID:

  • Go to any domain in Cloudflare Dashboard
  • The URL contains: dash.cloudflare.com/ACCOUNT_ID/...
  • Or find it in the Overview page sidebar

Installation & Configuration

Cloudflare supports two complementary deployment models for Model Context Protocol integration: connecting directly to Cloudflare’s managed Remote MCP servers over Streamable HTTP with OAuth 2.1, or running the local @cloudflare/mcp-server-cloudflare CLI package via npx with a scoped API token. For interactive IDE workflows in Cursor, Windsurf, or Claude Desktop, connecting to modular remote endpoints (such as https://observability.mcp.cloudflare.com/mcp or https://bindings.mcp.cloudflare.com/mcp via mcp-remote) eliminates local credential storage and keeps your context window lean. For headless CI/CD pipelines or local stdio setups, validate your claude_desktop_config.json syntax using our JSON Formatter & Validator before restarting your client.

Basic Setup

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "cloudflare": {
      "command": "npx",
      "args": ["-y", "mcp-server-cloudflare"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "your-token-here",
        "CLOUDFLARE_ACCOUNT_ID": "your-account-id"
      }
    }
  }
}

Zone-Specific Access

For single domain access:

{
  "mcpServers": {
    "cloudflare-prod": {
      "command": "npx",
      "args": ["-y", "mcp-server-cloudflare"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "token-for-prod-only",
        "CLOUDFLARE_ZONE_ID": "zone-id-for-example-com"
      }
    }
  }
}

Verify Installation

Restart your AI client and test:

You: List my Cloudflare zones

Claude: Here are your Cloudflare zones:

        | Domain         | Status  | Plan       |
        |----------------|---------|------------|
        | example.com    | Active  | Pro        |
        | myapp.io       | Active  | Free       |
        | staging.dev    | Active  | Free       |

Available Tools

DNS Management

ToolDescriptionExample Prompt
list_dns_recordsShow all DNS records”List DNS for example.com”
create_dns_recordAdd new record”Add A record for api”
update_dns_recordModify existing”Update www to new IP”
delete_dns_recordRemove record”Delete old-subdomain”

Workers Management

ToolDescriptionExample Prompt
list_workersShow all Workers”What Workers do I have?”
get_workerWorker details/code”Show my-api-worker code”
deploy_workerDeploy new version”Deploy this Worker code”
delete_workerRemove Worker”Delete test-worker”

R2 Storage

ToolDescriptionExample Prompt
list_r2_bucketsShow R2 buckets”List my R2 buckets”
list_r2_objectsObjects in bucket”What’s in assets bucket?”
get_r2_objectRead object”Read config.json”
put_r2_objectUpload object”Upload this file”

Security & Settings

ToolDescriptionExample Prompt
list_firewall_rulesShow firewall rules”What firewall rules exist?”
get_zone_settingsZone configuration”Show security settings”
get_analyticsTraffic analytics”Show traffic for today”

Practical Workflows

Workflow 1: DNS Management

Complete DNS overview and management:

You: Show me all DNS records for myapp.io and identify 
     any potential issues

Claude: Analyzing DNS records for myapp.io...

        **Current DNS Records:**
        
        | Type  | Name    | Content              | Proxied |
        |-------|---------|----------------------|---------|
        | A     | @       | 104.21.xx.xx         | ✅      |
        | A     | www     | 104.21.xx.xx         | ✅      |
        | CNAME | api     | api.railway.app      | ✅      |
        | MX    | @       | mail.provider.com    | ❌      |
        | TXT   | @       | v=spf1 include:...   | ❌      |
        | TXT   | _dmarc  | v=DMARC1; p=reject   | ❌      |
        
        **Potential Issues:**
        
        ⚠️ **Missing www redirect:**
        Both @ and www point to same IP, but no redirect rule.
        Consider adding a Page Rule to redirect www → @
        
        ⚠️ **No DKIM record found:**
        Email authentication incomplete. Add DKIM record 
        from your email provider.
        
        ✅ SPF and DMARC properly configured
        ✅ All web traffic proxied through Cloudflare

Workflow 2: Worker Deployment

Manage Cloudflare Workers:

You: List my Workers and their status

Claude: Here are your Cloudflare Workers:

        | Worker Name  | Routes                      | Status  |
        |--------------|-----------------------------| --------|
        | api-handler  | api.myapp.io/*              | Active  |
        | redirect-svc | myapp.io/r/*                | Active  |
        | image-resize | cdn.myapp.io/images/*       | Active  |
        | test-worker  | (no routes)                 | Inactive|
        
        **Usage (Today):**
        - Total requests: 45,230
        - CPU time: 12.3ms avg
        - Errors: 23 (0.05%)
        
        **Recommendations:**
        - test-worker has no routes - consider deleting
        - image-resize has highest CPU - review for optimization

You: Show me the code for api-handler

Claude: Here's the api-handler Worker code:

        ```javascript
        export default {
          async fetch(request, env) {
            const url = new URL(request.url);
            
            // Route to appropriate backend
            if (url.pathname.startsWith('/v1')) {
              return fetch('https://api-v1.backend.com' + url.pathname);
            }
            // ... rest of code
          }
        }

### Workflow 3: Security Audit

Review Cloudflare security settings:

```text
You: Audit security settings for example.com

Claude: **Security Audit for example.com**

        **SSL/TLS:**
        - Mode: Full (Strict) ✅
        - Minimum TLS: 1.2 ✅
        - HSTS: Enabled ✅
        
        **Firewall:**
        | Rule Name      | Action  | Expression           |
        |----------------|---------|----------------------|
        | Block bad bots | Block   | cf.client.bot        |
        | Rate limit API | Limit   | path contains "/api" |
        | Block countries| Block   | ip.country in {...}  |
        
        **Security Headers:**
        - X-Frame-Options: DENY ✅
        - X-Content-Type-Options: nosniff ✅
        - CSP: Not configured ⚠️
        
        **Recommendations:**
        1. Add Content-Security-Policy header
        2. Consider enabling Bot Fight Mode
        3. Review rate limiting thresholds
        
        **Security Level:** Good (8/10)

Workflow 4: R2 Storage Management

Manage R2 object storage:

You: Show my R2 buckets and usage

Claude: **R2 Storage Overview**

        | Bucket          | Objects | Size    | Class    |
        |-----------------|---------|---------|----------|
        | prod-assets     | 12,340  | 45.2 GB | Standard |
        | user-uploads    | 89,012  | 128 GB  | Standard |
        | backup-archive  | 5,678   | 320 GB  | Standard |
        
        **Monthly Costs (Estimated):**
        - Storage: $4.93
        - Class A ops: $0.45
        - Class B ops: $0.12
        - Egress: Free (Cloudflare benefit!)
        - **Total: ~$5.50/mo**
        
        **Recent Activity:**
        - user-uploads: 234 uploads today
        - prod-assets: 12,000 reads today

You: List files in prod-assets/images/

Claude: Files in prod-assets/images/:

        | File Name        | Size   | Last Modified |
        |------------------|--------|---------------|
        | logo.png         | 45 KB  | Dec 20        |
        | hero-banner.webp | 234 KB | Dec 22        |
        | product-1.jpg    | 156 KB | Dec 23        |
        | product-2.jpg    | 189 KB | Dec 23        |
        ...
        
        Showing 10 of 2,340 objects.

Workflow 5: Traffic Analytics

Understand your traffic patterns:

You: Show me traffic analytics for the last 7 days

Claude: **Traffic Analytics (Last 7 Days)**

        **Overview:**
        - Total requests: 2.4M
        - Unique visitors: 145,000
        - Bandwidth: 89 GB
        - Cached: 78%
        
        **Daily Breakdown:**
        | Date    | Requests | Visitors | Cache Hit |
        |---------|----------|----------|-----------|
        | Dec 24  | 380K     | 22,000   | 79%       |
        | Dec 23  | 420K     | 25,000   | 81%       |
        | Dec 22  | 356K     | 19,000   | 76%       |
        ...
        
        **Top Countries:**
        1. United States: 45%
        2. United Kingdom: 12%
        3. Germany: 8%
        4. Canada: 6%
        
        **Threats Blocked:**
        - SQL injection attempts: 45
        - XSS attempts: 23
        - Known bad bots: 1,234

Example Prompts

DNS Operations

# Reading
"List all DNS records for example.com"
"Show A records for api subdomain"
"What MX records do I have?"

# Creating
"Add an A record pointing api to 192.168.1.1"
"Create CNAME for blog pointing to ghost.io"
"Add TXT record for domain verification"

# Modifying
"Update www to point to new server"
"Change TTL for all A records to 300"
"Enable proxy for the api subdomain"

Workers Operations

# Listing and viewing
"What Workers do I have?"
"Show details of api-handler Worker"
"What routes are configured?"

# Management
"Show Worker logs from last hour"
"What's the CPU usage for my Workers?"
"List Worker KV namespaces"

Security Operations

# Viewing
"Show firewall rules for example.com"
"What's my SSL/TLS configuration?"
"List active page rules"

# Analytics
"Show blocked threats this week"
"What countries is traffic coming from?"
"Show bot traffic percentage"

Multiple Accounts/Zones

Organizations managing multiple Cloudflare accounts or dozens of production and staging zones should enforce strict blast-radius isolation across their MCP server definitions. Rather than generating an account-wide super-token, provision dedicated Cloudflare API tokens per environment (cf-production with Zone:Read, Analytics:Read, and Logs:Read, and cf-staging with Workers Scripts:Edit and DNS:Edit) and restrict each token’s Zone Resources to explicit domain IDs. When both server entries are active in your MCP client, you can instruct your AI assistant to compare staging Worker bindings and WAF rules against production before promoting a release, preventing accidental DNS or firewall regressions on customer-facing domains.

Different Accounts

{
  "mcpServers": {
    "cf-personal": {
      "command": "npx",
      "args": ["-y", "mcp-server-cloudflare"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "personal-token",
        "CLOUDFLARE_ACCOUNT_ID": "personal-account"
      }
    },
    "cf-company": {
      "command": "npx",
      "args": ["-y", "mcp-server-cloudflare"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "company-token",
        "CLOUDFLARE_ACCOUNT_ID": "company-account"
      }
    }
  }
}

Environment Separation

{
  "mcpServers": {
    "cf-production": {
      "env": {
        "CLOUDFLARE_API_TOKEN": "prod-readonly-token"
      }
    },
    "cf-staging": {
      "env": {
        "CLOUDFLARE_API_TOKEN": "staging-full-access-token"
      }
    }
  }
}

Security Best Practices

Securing edge infrastructure against prompt injection and unintended mutations requires combining Cloudflare’s granular API token permissions, Client IP Address Filtering, and Cloudflare Zero Trust MCP Server Portals. Never use your Cloudflare Global API Key in an MCP configuration; always generate a scoped API Token with an explicit expiration date and restrict allowed client IPv4/IPv6 CIDR ranges to your corporate VPN or static gateway. For enterprise teams deploying internal MCP servers on Cloudflare Workers, placing them behind a Cloudflare Zero Trust Access policy ensures every tool invocation is authenticated, rate-limited, and logged in your central SIEM.

Token Permissions

Use CaseRecommended Permissions
Reading onlyZone:Read, DNS:Read, Analytics:Read
DNS managementZone:Read, DNS:Edit
Worker deploymentZone:Read, Workers:Edit
Full managementAll relevant Edit permissions

For more on AI security best practices, see the Understanding AI Safety, Ethics, and Limitations guide.

Token Scoping

Scope tokens to specific zones:

  1. In token creation, under “Zone Resources”
  2. Select “Specific zone”
  3. Choose only the domains AI should access

Audit Logging

You: Show recent API activity for my account

Claude: Cloudflare Audit Log (Last 24h):

        | Time     | Action            | User/Token      | Zone       |
        |----------|-------------------|-----------------|------------|
        | 14:32    | DNS record create | mcp-token       | example.com|
        | 14:15    | Worker deploy     | mcp-token       | -          |
        | 12:00    | Page rule update  | admin@co.com    | myapp.io   |

Combining with Other MCPs

Connecting Cloudflare MCP servers with source control, application telemetry, and team messaging servers turns edge administration into a closed-loop engineering workflow. As we explore in AI Agents vs Agentic AI, edge Workers, D1 databases, and R2 buckets rarely exist in isolation; they route traffic to AWS or GCP backends and are versioned in GitHub repositories. Combining the Cloudflare Bindings and Observability MCP servers with GitHub, Sentry, and Slack MCP servers lets your AI agent inspect an edge 502 spike, diff the deployed Worker script against main, and post a root-cause summary to #ops automatically.

Cloudflare + GitHub

Deploy on code changes:

You: Check if the Worker code in GitHub differs from deployed

Claude: [Uses GitHub to read repo]
        [Uses Cloudflare to get deployed code]
        
        Comparison:
        - GitHub version: v2.3.1 (updated Dec 23)
        - Deployed version: v2.3.0 (deployed Dec 20)
        
        Differences found:
        - New rate limiting logic
        - Bug fix for timeout handling
        
        Would you like me to deploy the newer version?

Cloudflare + Slack

Alert on issues:

You: If error rate exceeds 1%, alert #ops

Claude: [Uses Cloudflare to monitor]
        [Uses Slack to alert]
        
        Monitoring active. Will post to #ops if error 
        rate exceeds 1%.

Troubleshooting

When troubleshooting Cloudflare MCP server issues, first verify whether your client is authenticating via OAuth 2.1 against a remote *.mcp.cloudflare.com endpoint or using a local CLOUDFLARE_API_TOKEN environment variable. You can validate any static API token directly from your terminal by running curl "https://api.cloudflare.com/client/v4/user/tokens/verify" -H "Authorization: Bearer <TOKEN>". Keep in mind that Cloudflare’s core REST API enforces a global rate limit of 1,200 requests per 5-minute window per user or token, so bulk DNS record migrations should be batched or executed via Terraform/Wrangler rather than individual sequential tool calls.

Issue: “Authentication error”

Solutions:

CauseSolution
Invalid tokenRegenerate API token
Token expiredCheck token status in dashboard
Wrong account IDVerify account ID
Insufficient permissionsAdd required scopes to token

Issue: “Zone not found”

Solutions:

  • Verify zone ID is correct
  • Check token has access to that zone
  • Ensure domain is active in Cloudflare

Issue: “Rate limited”

Solutions:

  • Reduce request frequency
  • Batch operations where possible
  • Check Cloudflare API limits

ServerComplements Cloudflare By…
AWS MCPBackend infrastructure
GitHub MCPCode deployment source
Slack MCPAlerting and notifications
Memory MCPRemembering configurations

Summary

Cloudflare MCP Server enables AI-powered edge management:

  • ✓ DNS - Complete record management
  • ✓ Workers - Deploy and manage edge functions
  • ✓ R2 - Object storage operations
  • ✓ Security - Firewall and settings
  • ✓ Analytics - Traffic insights
  • ✓ Remote MCP (2025) - Cloud-hosted, no local setup

2025 Cloudflare MCP Features:

  • Remote MCP servers on global edge
  • Workers AI - 4000% YoY inference growth
  • MCP Server Portals - enterprise management
  • Python support for building MCP servers
  • AI Gateway - security and monitoring

Best use cases:

  • DNS record management
  • Worker deployment automation
  • Security auditing
  • Traffic analysis
  • Multi-zone management

Security checklist:

  • ☐ Create scoped API tokens
  • ☐ Limit to specific zones
  • ☐ Start with read-only access
  • ☐ Monitor audit logs
  • ☐ Rotate tokens periodically

Next: Learn about Sentry MCP Server → for error monitoring.

Combining scoped API tokens with Workers, D1, and R2 unlocks globally distributed MCP edge computing with sub-50ms tool execution.


Questions about Cloudflare MCP? Check the Cloudflare Agents & MCP Documentation or the Official Cloudflare MCP GitHub Repository.

Frequently Asked Questions

What Cloudflare services can MCP manage?

Cloudflare offers official remote MCP servers (2025) for DNS, Workers, R2, KV, Firewall rules, and more. MCP Server Portals provide centralized management and security.

What credentials do I need?

You need a Cloudflare API token with appropriate permissions. Create tokens at dash.cloudflare.com under 'API Tokens'. Use scoped tokens, not global API keys.

Can AI deploy my Workers?

Yes, if you grant the Worker deployment permission. For safety, start with read-only access and carefully evaluate before enabling write operations.

Is it safe to manage DNS with AI?

For reading DNS records, very safe. For modifying - use with caution. Consider testing changes on staging domains first and having rollback procedures.

Can I manage multiple Cloudflare accounts?

Yes! Configure separate MCP servers with different API tokens for each account, just like with AWS.

Does this work with Cloudflare Zero Trust?

Depends on the MCP server implementation. Some community servers support Access policies and Gateway rules.

How do I limit AI access to specific zones?

Create a scoped API token that only has access to specific zones/domains. Cloudflare's token permissions are very granular.

Are there rate limits?

Cloudflare has API rate limits. The MCP server handles these, but avoid rapid bulk operations. This architecture makes MCP edge computing on Cloudflare Workers, KV, D1, and R2 one of the lowest-latency patterns for deploying remote agent tools.

Written by Rajesh Praharaj

Product Leader & AI Builder

Product leader and AI builder focused on practical LLM systems, Model Context Protocol (MCP) integrations, agentic workflows, and free browser-based tools for product & engineering teams.

Was this page helpful?

Let us know if you found what you were looking for.