Skip to main content
Glama

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

cf_system_status

Verify auth, account id, zone map and capability reachability

cf_d1_query

Execute SQL against a named D1 database (rows, changes, duration)

cf_d1_list_databases

List D1 databases with ids and creation timestamps

cf_d1_schema

Table/view DDL for a database, optionally a single table

cf_list_workers

Workers with environments, routes, deployments, modified dates

cf_kv_get / cf_kv_set

Read/write Workers KV keys (ttl + metadata)

cf_r2_list_buckets

List R2 buckets (cursor pagination)

cf_dns_list / cf_dns_upsert

DNS record query + idempotent create/update

cf_search_docs

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 point

Every 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

CLOUDFLARE_API_TOKEN

API token (never printed, only last 4 chars in status)

CLOUDFLARE_ACCOUNT_ID

Account id used for account scoped endpoints

CLOUDFLARE_ZONE_MAP

{"example.com": "<zone_id>"} or example.com=<zone_id>,...

CLOUDFLARE_API_BASE

Override API base (defaults to v4 endpoint)

CLOUDFLARE_MCP_TIMEOUT / CLOUDFLARE_MCP_RETRIES

HTTP timeout / retry budget

CLOUDFLARE_MCP_WRANGLER_FALLBACK

0 disables the local wrangler fallback

CLOUDFLARE_MCP_DOCS_DIRS

os.pathsep separated markdown dirs indexed for cf_search_docs

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-mcp

Tests

TMPDIR=/var/tmp/testing ~/.local/share/cloudflare-mcp/runtime/bin/pytest

Tests mock all Cloudflare API traffic (no network, no tokens) and run scratch files under /var/tmp/testing only — never /tmp.

Available Tools

17 tools
cf_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

    B3.4/5.0

    Scored across 17 tools

    Disambiguation4/5

    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.

    Naming Consistency4/5

    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.

    Tool Count4/5

    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.

    Completeness2/5

    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

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables 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.
      13
      2
      MIT
    • A
      license
      Not graded
      quality
      F
      maintenance
      Enables 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.
      129
      Apache 2.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables 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.
      -