cloudflare-mcp
Provides tools for interacting with Cloudflare infrastructure, including D1 databases (SQL queries, listing databases, schema inspection), Workers (listing workers with environments, routes, deployments), KV (reading/writing keys with TTL and metadata), R2 buckets (listing with pagination), DNS records (listing and idempotent create/update), and on-demand Cloudflare documentation search.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@cloudflare-mcp what DNS records do I have for example.com?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
cloudflare-mcp
Unified Model Context Protocol server for Cloudflare infrastructure. It replaces
fragmented reference markdown (and ad-hoc wrangler guessing) with deterministic,
typed tool calls:
Tool | Purpose |
| Verify auth, account id, zone map and capability reachability |
| Execute SQL against a named D1 database (rows, changes, duration) |
| List D1 databases with ids and creation timestamps |
| Table/view DDL for a database, optionally a single table |
| Workers with environments, routes, deployments, modified dates |
| Read/write Workers KV keys (ttl + metadata) |
| List R2 buckets (cursor pagination) |
| DNS record query + idempotent create/update |
| On-demand documentation/snippet lookup (keeps context clean) |
Architecture
cloudflare_mcp/
config.py environment configuration + zone mapping + token masking
client.py Cloudflare v4 REST client (retries, pagination)
wrangler.py wrangler config discovery/parsing + local CLI fallback runner
result.py the {ok, result|error} envelope and the safe() wrapper
data/ bundled documentation corpus (shipped as package data)
d1.py D1 listing, SQL execution, schema inspection
workers.py Worker inventory, routes, deployments, wrangler tail
storage.py KV and R2 operations
dns.py Zones and DNS record CRUD
docs.py Keyword/semantic scoring over a bundled corpus + local markdown dirs
server.py MCP tool definitions and stdio entry pointEvery file stays well under the 300-400 line limit; tools return a stable
{"ok": bool, "result" | "error"} envelope.
Related MCP server: Cloudflare MCP Server
Configuration
Variable | Meaning |
| API token (never printed, only last 4 chars in status) |
| Account id used for account scoped endpoints |
|
|
| Override API base (defaults to v4 endpoint) |
| HTTP timeout / retry budget |
|
|
|
|
When no token is configured but a local wrangler.toml|json|jsonc exists, D1 and
Worker operations fall back to the local wrangler CLI.
Install
python3 -m venv ~/.local/share/cloudflare-mcp/runtime
~/.local/share/cloudflare-mcp/runtime/bin/pip install ".[dev]"
install -m 0755 shim/cloudflare-mcp ~/.local/bin/cloudflare-mcpTests
TMPDIR=/var/tmp/testing ~/.local/share/cloudflare-mcp/runtime/bin/pytestTests mock all Cloudflare API traffic (no network, no tokens) and run scratch
files under /var/tmp/testing only — never /tmp.
Available Tools
17 toolscf_access_apps_listA
List Cloudflare Access protected applications (domains, session durations, identity provider bindings).
Inputs: no named parameters. Returns: The MCP output envelope every tool returns.
cf_ai_modelsA
List or search Cloudflare Workers AI models (e.g. '@cf/meta/llama-3', embeddings, text generation, vision). Returns model metadata and capabilities.
Inputs: search. Returns: The MCP output envelope every tool returns.
cf_d1_list_databasesA
List all D1 (serverless SQLite) databases in the account with ids, creation timestamps and local wrangler bindings.
Inputs: no named parameters. Returns: The MCP output envelope every tool returns.
cf_d1_queryA
Execute a SQL statement (SELECT/INSERT/UPDATE/DDL) against a named D1 database or database id. Returns columns, rows, rows_affected and duration. Supports positional parameter binding on the REST path.
Inputs: sql (required), database (required), params. Returns: The MCP output envelope every tool returns.
cf_d1_schemaA
Inspect the table and view DDL of a D1 database (optionally a single table), so an agent can write valid SQL without a full schema dump.
Inputs: database (required), table. Returns: The MCP output envelope every tool returns.
cf_dns_listB
List DNS records of a zone (optional type/name filter) with content, TTL and proxy status. Zone may be a domain or an id in CLOUDFLARE_ZONE_MAP.
Inputs: zone (required), name, type, limit. Returns: The MCP output envelope every tool returns.
cf_dns_upsertB
Create or update a DNS record in a zone (idempotent by type + name). Set type/name/content plus optional ttl (1=automatic), proxied flag and comment.
Inputs: name (required), type (required), zone (required), content (required), +3 more. Returns: The MCP output envelope every tool returns.
cf_email_destinationsA
List verified destination email addresses for Cloudflare Email Routing under the active account.
Inputs: no named parameters. Returns: The MCP output envelope every tool returns.
cf_email_routing_rulesB
List Cloudflare Email Routing rules for a zone (matchers, forward actions, enabled status and priorities). Useful to inspect inbound routing for domains.
Inputs: zone. Returns: The MCP output envelope every tool returns.
cf_kv_getB
Read one key (value + metadata + expiration) from a Workers KV namespace by namespace id or namespace title.
Inputs: key (required), namespace (required). Returns: The MCP output envelope every tool returns.
cf_kv_setB
Write one key/value pair into a Workers KV namespace. Optional ttl in seconds (max 604800) and JSON metadata; set is_json when the value is a JSON document that should be validated before write.
Inputs: key (required), value (required), namespace (required), ttl, +2 more. Returns: The MCP output envelope every tool returns.
cf_list_workersB
List deployed Cloudflare Workers with environments, routes, deployment history and modified dates.
Inputs: include_routes. Returns: The MCP output envelope every tool returns.
cf_r2_list_bucketsB
List R2 buckets in the account with creation time, location and storage class. Pass cursor for the next page.
Inputs: limit, cursor. Returns: The MCP output envelope every tool returns.
cf_search_docsA
On-demand search over Cloudflare configuration/architecture guidance. Returns targeted snippets and code samples only - use this instead of loading manuals or guessing wrangler/wrangler-free API syntax.
Inputs: query (required), limit. Returns: The MCP output envelope every tool returns.
cf_system_statusA
Verify Cloudflare API authentication, the active account id, masked token state, zone mapping and which product capabilities are reachable.
Inputs: no named parameters. Returns: The MCP output envelope every tool returns.
cf_tunnels_listB
List Cloudflare Zero Trust Tunnels (cloudflared connectors), their active status, tunnel id, connectors and configuration.
Inputs: is_deleted. Returns: The MCP output envelope every tool returns.
cf_vectorize_list_indexesA
List Cloudflare Vectorize vector database indexes (dimensions, metric, creation timestamp, description).
Inputs: no named parameters. Returns: The MCP output envelope every tool returns.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 17 tools
Each tool targets a distinct Cloudflare resource and action (KV, DNS, D1, R2, tunnels, Access, email routing, AI, Vectorize), so misselection risk is low. The only mild friction is that read-only list tools interleave with read/write pairs, but purposes remain clear.
All tools share a consistent cf_ prefix and snake_case style. However the ordering is mixed: cf_kv_get / cf_dns_list (resource_verb) alongside cf_tunnels_list / cf_vectorize_list_indexes (resource_list) and cf_list_workers (verb_resource), a minor deviation from a single pattern.
17 tools for the very broad Cloudflare domain (DNS, KV, D1, R2, Workers, Zero Trust, email, AI) is reasonable and each tool maps to a meaningful capability. It sits at the upper end of comfortable but is not bloated.
Large lifecycle gaps exist: KV has get/set but no delete or list, DNS lacks delete, and most products (R2, Workers, Vectorize, tunnels, Access, email) are read/list-only with no create or delete operations. Agents will hit dead ends for mutation workflows beyond DNS upsert and D1 SQL.
Related MCP Connectors
Approval-gated Cloudflare ops for agents: DNS, email auth, Pages, cache, Turnstile, tokens.
The agent-native cloud: database, functions, AI, storage, computers. 53 tools. OAuth or API key.
Provides capabilities that let LLM agents perform a range of infrastructure management tasks.
Read zones, DNS, Workers, storage and audit logs; change DNS records and purge cache in Cloudflare.
Related MCP Servers
- AlicenseBqualityDmaintenanceExposes Cloudflare DNS, security, redirects and zone-settings functionality as structured tools that AI assistants like Claude Desktop can invoke directly.18MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to manage Cloudflare resources through natural language, including DNS records, zone management, Workers KV storage, cache purging, and analytics. Supports comprehensive Cloudflare operations with secure API token authentication.132MIT
- AlicenseNot gradedqualityFmaintenanceEnables interaction with the complete Cloudflare API using a codemode pattern that allows agents to search the OpenAPI spec and execute API calls via JavaScript. This approach minimizes token usage by keeping the massive specification on the server and only returning relevant results.129Apache 2.0
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage Cloudflare infrastructure including DNS records, cache purging, SSL settings, Workers, and analytics through the Cloudflare API. Eliminates dashboard context-switching by allowing natural language control of domain management and infrastructure operations.-