Claude Code Cloudflare MCP Server Setup

Written by Michael Lip · Solo founder of Zovo · $400K+ on Upwork · 100% JSS Join 50+ builders · More at zovo.one

The Cloudflare MCP server lets Claude Code interact with your Cloudflare Workers, Pages, KV stores, R2 buckets, and DNS settings through the Model Context Protocol. This guide covers setup, authentication with API tokens, and practical workflows for managing Cloudflare edge infrastructure.

The Problem

Cloudflare developers manage Workers, Pages, KV namespaces, R2 storage, and DNS records across the Cloudflare dashboard and Wrangler CLI. Claude Code has no native Cloudflare awareness. Without MCP, you describe your Workers config, paste Wrangler errors, and manually copy deployment outputs into your Claude Code session. Edge computing has enough complexity without this overhead.

Quick Solution

  1. Create a Cloudflare API token with the permissions you need:
Cloudflare Dashboard > My Profile > API Tokens > Create Token
Permissions: Workers Scripts (Edit), Workers KV (Edit), Pages (Edit)
Zone: your-domain.com
  1. Add the Cloudflare MCP server to .claude/settings.json:
{
  "mcpServers": {
    "cloudflare": {
      "command": "npx",
      "args": ["-y", "@anthropic/mcp-server-cloudflare"],
      "env": {
        "CLOUDFLARE_API_TOKEN": "your-api-token",
        "CLOUDFLARE_ACCOUNT_ID": "your-account-id"
      }
    }
  }
}
  1. Restart Claude Code and verify the connection:
claude /mcp
# Should show "cloudflare" with available tools
  1. Test with a query:
List all Workers in my Cloudflare account
  1. Ensure Wrangler is installed for deployment operations:
npm install -g wrangler
wrangler login

How It Works

The Cloudflare MCP server wraps the Cloudflare API v4, exposing operations as structured tools that Claude Code can invoke. When Claude Code starts, it spawns the MCP server, which authenticates using your API token.

Available tools typically include: listing and deploying Workers, reading and writing KV pairs, managing R2 buckets and objects, querying DNS records, and checking Pages deployment status. Each tool accepts typed parameters and returns structured responses.

For deployment workflows, the MCP server can trigger Wrangler deployments or call the Cloudflare API directly. Claude Code can read your wrangler.toml configuration, understand your Worker bindings (KV, R2, D1, Durable Objects), and suggest changes based on your infrastructure.

The API token scopes control exactly what Claude Code can do. A read-only token lets Claude Code inspect your setup, while edit tokens allow deployments and configuration changes.

Common Issues

API token scope insufficient: If Claude Code gets 403 errors, your API token is missing the required permission. Create a new token with broader scope or add the specific permission (e.g., Workers KV Storage Edit).

Account ID mismatch: If you have multiple Cloudflare accounts (personal + team), ensure CLOUDFLARE_ACCOUNT_ID points to the correct one. Find it in the Cloudflare dashboard under the domain overview page.

Wrangler and MCP conflicts: If both Wrangler CLI and the MCP server try to deploy simultaneously, you may get version conflicts. Use one approach per session – either MCP-triggered deploys or manual Wrangler deploys.

Example CLAUDE.md Section

# Cloudflare Infrastructure

## MCP Server
- Cloudflare MCP configured in .claude/settings.json
- Account ID: abc123def456
- Primary zone: myapp.com

## Workers
- api-worker: Handles /api/* routes (src/worker.ts)
- auth-worker: JWT validation (src/auth-worker.ts)
- cron-worker: Scheduled tasks (runs every 5min)

## Bindings
- KV Namespace: CACHE (production), CACHE_DEV (development)
- R2 Bucket: assets (public), uploads (private)
- D1 Database: main-db
- Durable Objects: RateLimiter, SessionStore

## Deployment
- Use `wrangler deploy` for Workers
- Pages auto-deploys from main branch
- NEVER deploy Workers during peak hours (09:00-17:00 UTC)
- Always test with `wrangler dev` before deploying

Best Practices



I'm a solo developer in Vietnam. 50K Chrome extension users. $500K+ on Upwork. 5 Claude Max subscriptions running agent fleets in parallel. These are my actual CLAUDE.md templates, orchestration configs, and prompts. Not a course. Not theory. The files I copy into every project before I write a line of code. **[See what's inside →](https://zovo.one/lifetime?utm_source=ccg&utm_medium=cta-default&utm_campaign=claude-code-cloudflare-mcp)** $99 once. Free forever. 47/500 founding spots left.

Related Reading

Built by theluckystrike. More at zovo.one