Wrangler MCP — Cloudflare Workers for AI Agents
MCP server for managing Cloudflare Workers, KV, R2, and D1 from AI agents. Deploy serverless functions, manage storage, and query databases through Claude Code tool calls.
What it is
Wrangler MCP is a Model Context Protocol server that exposes Cloudflare's developer platform to AI agents. It wraps the Wrangler CLI, enabling Claude Code and other MCP-compatible agents to deploy Workers, read and write KV namespaces, manage R2 object storage, and query D1 databases through tool calls.
This MCP server targets developers who use AI agents for infrastructure management. Instead of switching to a terminal to run wrangler commands, you tell your agent what you need and it handles the Cloudflare API interactions.
How it saves time or tokens
Managing Cloudflare resources through the dashboard or CLI requires context-switching from your coding environment. With Wrangler MCP, your AI agent handles deployments, KV writes, and D1 queries inline during a coding session. A single natural language instruction like 'deploy this worker to production' triggers the correct sequence of wrangler commands.
How to use
- Install the Wrangler MCP server in your Claude Code configuration.
- Authenticate with your Cloudflare API token.
- Use natural language to manage Cloudflare resources.
// Claude Code MCP configuration
{
"mcpServers": {
"wrangler": {
"command": "npx",
"args": ["wrangler", "mcp", "server"],
"env": {
"CLOUDFLARE_API_TOKEN": "your-api-token"
}
}
}
}
Example
// Example Worker deployed via Wrangler MCP
export default {
async fetch(request: Request, env: Env): Promise<Response> {
// Read from KV
const value = await env.MY_KV.get('config');
// Query D1 database
const result = await env.DB.prepare(
'SELECT * FROM users WHERE active = ?'
).bind(1).all();
return Response.json({
config: value,
users: result.results
});
}
};
Related on TokRepo
- MCP integrations — Other MCP servers for infrastructure management
- DevOps tools — Deployment and infrastructure automation tools
Common pitfalls
- The Cloudflare API token must have the correct permissions for each resource type (Workers, KV, R2, D1). A token with only Workers permissions cannot manage KV namespaces.
- Wrangler MCP executes real deployments. There is no dry-run mode by default. Test against a staging Cloudflare account before using it on production resources.
- Large R2 object uploads through MCP may time out. For bulk data transfers, use the Wrangler CLI directly with streaming support.
Frequently Asked Questions
Wrangler MCP supports Workers (deploy, update, delete), KV namespaces (read, write, list, delete), R2 object storage (upload, download, list), and D1 databases (query, migrations). It covers the most commonly used Cloudflare developer services.
Yes. Wrangler MCP is an MCP server that integrates with Claude Code and any other MCP-compatible AI agent. You configure it in your Claude Code settings and the agent can call Cloudflare tools during coding sessions.
The MCP server itself is free and open source. You pay standard Cloudflare pricing for the resources you use (Workers invocations, KV reads/writes, R2 storage, D1 queries). Cloudflare offers generous free tiers for all these services.
Yes, but with caution. Wrangler MCP executes real Cloudflare API calls. Set up separate API tokens for staging and production environments. Review the agent's planned actions before confirming production deployments.
Wrangler MCP uses a Cloudflare API token passed as an environment variable. You create the token in the Cloudflare dashboard with specific permissions for the services you want to manage. The token is stored in your MCP configuration file.
Citations (3)
- Cloudflare Workers SDK GitHub— Wrangler is the CLI for Cloudflare Workers development
- Cloudflare Workers Docs— Cloudflare Workers serverless platform documentation
- MCP Specification— Model Context Protocol specification for AI tool integration
Related on TokRepo
Source & Thanks
Created by Cloudflare. Official MCP server.