How to connect the Cloudflare MCP with Claude Code (5 steps)

Cloudflare Workers developers spend a surprising amount of time in the dashboard.
Checking deployment statuses, reading KV entries, updating DNS records, and reviewing firewall events all require leaving the terminal, even when the underlying task is purely mechanical.
For teams shipping to the edge frequently, that context switch adds up fast.
To help your developers manage Cloudflare infrastructure directly from their coding session, we'll show you how to connect Cloudflare with Merge Agent Handler's Cloudflare MCP server.
How it works
Merge Agent Handler acts as a secure bridge between Claude Code and Cloudflare's API. When you configure a Tool Pack and Registered User, Merge generates a unique MCP URL that Claude Code accesses via HTTP, combined with an API key (generated in Merge Agent Handler) for authentication.
Here's how the command looks before you add your specific MCP URL and API key:
Claude Code sends requests to that MCP URL, and Merge handles authentication and API calls to Cloudflare on the backend. You don't manage Cloudflare API tokens locally or rotate credentials when team members change. Merge handles token storage from here on.
Prerequisites
Before getting started, you'll need the following:
- A Merge Agent Handler account
- Claude Code installed (run <code class="blog_inline-code">
claude --version</code>to confirm) - A Cloudflare account with access to the zones and resources you want to connect
Related: A guide to using the Airtable MCP with Claude Code
1. Create a Tool Pack
Log into Merge Agent Handler and navigate to Tool Packs. Click Create Tool Pack and give it a name tied to the use case, like Worker deployment agent.

Under connectors, select Cloudflare and choose the tools to enable.

For most development workflows, enabling Worker retrieval, KV namespace access, and DNS record listing covers the common cases. Enable write tools if you want your agent to deploy scripts, update KV entries, or modify DNS records directly.
Save the Tool Pack. You'll return here in step 4 to copy your MCP URL.
2. Add a Registered User
Inside your Tool Pack, create a Registered User. This is the identity context under which your agent operates: the account it acts on behalf of when calling Cloudflare's API.

Give it a name that maps to your environment, like dev-local or your own name. Once created, Merge generates a unique MCP URL scoped to this user.
3. Authenticate Cloudflare
From the Registered User detail page, click Add Connector and select Cloudflare. You can then complete the authentication flow to grant your agent access to the Cloudflare account and zones you want to connect.

Once authenticated, Merge stores and manages the credentials. You won't need to re-authenticate unless you revoke access.
4. Gather your credentials
You need two things before configuring Claude Code:
1. MCP URL: found on the Tool Pack detail page under the Registered User you just created. It looks like this:
2. API key: found in Settings > API Keys in your Merge Agent Handler dashboard. Create one if you don't have one yet.
Keep both handy for the next step.
5. Configure Claude Code with Cloudflare
Run the following command in your terminal, substituting your actual MCP URL and API key:
Verify the connection registered: <code class="blog_inline-code">claude mcp list</code>
<code class="blog_inline-code">agent-handler</code> should appear in the output with a connected status.
To confirm the connector is accessible, open a Claude Code session and run a command like "List my Cloudflare Workers and show the deployment status of the most recently updated one."
You should see an output that looks something like the following:

{{this-blog-only-cta}}
Cloudflare MCP FAQ
In case you have more questions on setting up and using the Cloudflare MCP in Claude Code, we've addressed several more commonly-asked questions below.
What can you do once the Cloudflare MCP is connected to Claude Code?
With Cloudflare connected, Claude Code can:
- List and retrieve Workers: pull up deployed scripts by name, check their routes, and read their current configuration without leaving the terminal
- Read and write KV entries: fetch or update key-value pairs in any namespace your agent has access to, useful for inspecting feature flags or cached state
- Manage DNS records: list, create, or update DNS records across your zones directly from a coding session
- Check Pages deployments: retrieve the status and metadata of recent Pages deployments so you can confirm a build succeeded without opening the dashboard
- Inspect zone analytics: pull traffic and error rate data for a zone to verify a deployment didn't introduce a regression
- Query firewall and security events: surface recent security events or firewall rule matches to investigate anomalies during a debugging session
Why use Merge Agent Handler vs. a self-hosted Cloudflare MCP server?
You can build a self-hosted MCP server that calls Cloudflare's API directly. For a solo developer working on a personal account, that approach is manageable. You create a Cloudflare API token, write a small server, and connect it to Claude Code.
It breaks down at the team level. Self-hosting means each developer manages their own Cloudflare API token, scoped however they configured it. There's no central place to enforce which zones or resources an agent is allowed to touch, no audit log of what agents read or modified, and no clean offboarding process when someone leaves. Token rotation becomes a manual coordination problem.
Merge Agent Handler is a managed MCP layer. It centralizes authentication, scopes access per Tool Pack and Registered User so each agent only reaches the zones and resources you explicitly allow, and logs every tool call. When you need to audit what an agent queried or changed in Cloudflare, the record is there.
For teams running agents against production Cloudflare infrastructure, Merge Agent Handler removes the per-developer credential problem and adds the access controls that matter in shared environments.
Why connect Cloudflare to Claude Code?
Cloudflare sits at the edge of your infrastructure. Every DNS change, Worker deployment, and KV update has a live effect on production traffic. Developers managing that infrastructure from a coding session currently have to leave the terminal every time they need to check or change something in Cloudflare.
With the Cloudflare MCP connected, Claude Code can query Workers, read KV state, check DNS, and surface analytics without a context switch. That means you can deploy a Worker, ask Claude to verify the route is live and the KV namespace is populated correctly, and confirm traffic is hitting the right handler, all in one session.

.png)


.png)