Skip to main content
Glama

Cloudflare MCP server

An MCP server for the Cloudflare API. Claude can use it to look up accounts, zones, DNS records, zone settings, SSL/TLS and certificates, page rules, redirect rules, Zero Trust Access applications and traffic analytics. Separately named write tools can create, change and delete DNS records, purge the cache, set the SSL mode, and turn Always Use HTTPS and development mode on or off.

There is one named tool per action and no generic "call any API path" tool: every tool calls fixed Cloudflare paths with validated arguments (IDs must be 32 hex characters, names must be domain names), so a tool can only do what its name says.

It uses the same framework as Cititec's other MCP servers: TypeScript, @modelcontextprotocol/sdk, a stdio transport, vitest tests, tsup and a Docker image. It is built to run on the Cititec MCP host, which runs one container per connection and turns every write into a proposal that a person approves before it runs.

Configuration

Variable

CLOUDFLARE_API_TOKEN

An API token (never a Global API Key). See "API token permissions".

LOG_LEVEL

debug, info (default), warn, error. Logs go to stderr; tool arguments and the token are never logged.

The token is sent only to https://api.cloudflare.com/client/v4, as a Bearer header, and is removed from any error text.

Related MCP server: Cloudflare MCP Server

Tools

Results keep the useful fields only, and every result is capped at 60,000 characters. Where a tool takes zone, it accepts the zone name (example.com.au) or its ID; by name it costs one extra request to look the ID up.

Read tools

Tool

Cloudflare API

Notes

cloudflare_list_accounts

GET /accounts

ID, name, type. Filter by name

cloudflare_list_zones

GET /zones

Filter by exact name, text in the name (contains:), account ID or name, status

cloudflare_get_zone

GET /zones/{id} (or by name)

Status, name servers (and the ones before Cloudflare), account, plan, page rule quota, the token's permissions on it

cloudflare_list_dns_records

GET /zones/{id}/dns_records

Filter by type, exact name (@, www or the full name), text in the name, text in the content, proxied

cloudflare_get_dns_record

GET /zones/{id}/dns_records/{id}

cloudflare_get_zone_settings

GET /zones/{id}/settings

The main settings (SSL, HTTPS, TLS, HSTS, cache, security level, HTTP/3, ...); full for all

cloudflare_get_ssl_status

GET /zones/{id}/settings, GET /zones/{id}/ssl/certificate_packs?status=all

SSL mode, Always Use HTTPS, minimum TLS, HSTS; certificate packs with authority, status and expiry

cloudflare_list_page_rules

GET /zones/{id}/pagerules

cloudflare_list_redirect_rules

GET /zones/{id}/rulesets/phases/http_request_dynamic_redirect/entrypoint

Single Redirects. A zone without any returns an empty list

cloudflare_list_access_apps

GET /accounts/{id}/access/apps

Name, type, domains, session duration, identity providers, policy names. Client secrets, keys and policy members (emails) are never returned

cloudflare_get_zone_analytics

POST /graphql (httpRequests1dGroups, read only)

Requests, cached requests, bandwidth, threats, page views, unique visitors per day for 1 to 30 days

Write tools

Every write tool takes zone_id and zone_name. Before changing anything it reads the zone and stops if the ID is not that zone, so a wrong ID cannot change another client's zone, and an approver sees the domain name in the proposal. Record changes also read the record first and stop if it is not the one named (current_name, or name and type for a delete). Then the tool sends exactly one change, which is never retried.

Tool

Cloudflare API

Notes

cloudflare_create_dns_record

POST /zones/{id}/dns_records

A, AAAA, CNAME, MX, TXT, NS. Content is checked for the type (an IP address, a host name). TTL 1 (automatic) by default; proxied only for A/AAAA/CNAME

cloudflare_update_dns_record

PATCH /zones/{id}/dns_records/{id}

Content, name, TTL, proxied, MX priority, comment ("" removes it); not the type. Returns the record before and after

cloudflare_delete_dns_record

DELETE /zones/{id}/dns_records/{id}

Destructive. Returns the deleted record so it can be recreated

cloudflare_purge_cache_urls

POST /zones/{id}/purge_cache (files)

Up to 30 URLs, each on the zone or a subdomain of it

cloudflare_purge_cache_everything

POST /zones/{id}/purge_cache (purge_everything)

Destructive: every visitor's next requests go to the origin

cloudflare_set_ssl_mode

PATCH /zones/{id}/settings/ssl

off, flexible, full, strict

cloudflare_set_always_use_https

PATCH /zones/{id}/settings/always_use_https

cloudflare_set_development_mode

PATCH /zones/{id}/settings/development_mode

Turns itself off after 3 hours

Destructive tools have the MCP annotation destructiveHint: true (all others false), and the package exports their names (DESTRUCTIVE_TOOL_NAMES) so a host can gate them separately. SRV, CAA and other structured record types can be read but not written by these tools.

API token permissions

Create a custom user API token (dash.cloudflare.com > My Profile > API Tokens > Create Token > Create Custom Token). Not a Global API Key, and not an account-owned token: an account-owned token works in one account only, and Cititec manages each client in its own account. Create the token on a user that is a member of every client account, preferably a dedicated service user (Cloudflare's 1,200 requests per 5 minutes is counted per user, including that user's dashboard use).

Read-only token (the host's -ro.env):

Scope

Permission

Level

Used by

Account

Account Settings

Read

cloudflare_list_accounts

Account

Access: Apps and Policies

Read

cloudflare_list_access_apps

Zone

Zone

Read

zone lookups, cloudflare_list_zones, cloudflare_get_zone

Zone

DNS

Read

cloudflare_list_dns_records, cloudflare_get_dns_record

Zone

Zone Settings

Read

cloudflare_get_zone_settings, cloudflare_get_ssl_status

Zone

SSL and Certificates

Read

cloudflare_get_ssl_status (certificate packs)

Zone

Page Rules

Read

cloudflare_list_page_rules

Zone

Single Redirect (listed as Dynamic Redirect on older dashboards)

Read

cloudflare_list_redirect_rules

Zone

Analytics

Read

cloudflare_get_zone_analytics

Write token (the host's -rw.env, used for everyone granted rw, so it needs the read permissions too): everything above, with these levels instead:

Scope

Permission

Level

Used by

Zone

DNS

Edit

create, update and delete DNS records

Zone

Zone Settings

Edit

SSL mode, Always Use HTTPS, development mode

Zone

Cache Purge

Purge

both purge tools

For both tokens:

  • Account Resources: Include > All accounts. Zone Resources: Include > All zones from all accounts (or All zones). New client accounts and zones are then covered without editing the token.

  • Client IP Address Filtering: Is in > the MCP host's public IP address, so a leaked token is useless elsewhere.

  • TTL: an end date, and a reminder to rotate it.

A tool whose permission is missing returns an auth error (HTTP 403, code 9109 "Unauthorized to access requested resource"); the other tools keep working. Nothing here needs Workers, Tunnels, Access edit, Billing, Members or API Tokens permissions.

Errors and rate limits

A failed call returns isError: true with a first line for people and a JSON line for programs, also in structuredContent:

Error: Cloudflare rate-limited the request (HTTP 429): GET /zones. Try again in 300 s.
{"error":"rate_limited","message":"...","retry_after_seconds":300}

error is one of rate_limited, auth, invalid_input, not_found, api_error, config.

Cloudflare allows 1,200 requests per 5 minutes per user (dashboard and API tokens together) and 200 per second per IP; going over blocks every call for 5 minutes (limits). Following the Cititec fleet policy:

  • a read that gets HTTP 429 (or 503 with Retry-After) is retried once, and only when Retry-After is at most 10 s;

  • a write is never retried; the error says it was not retried;

  • otherwise the tool returns rate_limited with retry_after_seconds (Retry-After, or 300 when Cloudflare gives none).

Most tools make one request; a zone given by name adds one; cloudflare_get_ssl_status makes two; writes make two (zone check, change) and record updates and deletes three (zone check, record check, change). The Cititec MCP host also limits calls for everyone together, from these figures.

Development

npm ci
npm run lint    # tsc --noEmit
npm test        # vitest
npm run build   # tsup -> dist/index.js

Run it over stdio with CLOUDFLARE_API_TOKEN=... node dist/index.js.

Releases: commits to main with Conventional Commit messages are released by the Cititec release workflow (semantic-release), which tags the version and pushes ghcr.io/cititec-pty-ltd/cloudflare-mcp:v<version> and :latest.

Licence

Apache 2.0. See LICENSE and NOTICE.

Available Tools

19 tools
cloudflare_create_dns_recordA

Create a DNS record (A, AAAA, CNAME, MX, TXT or NS) in a zone. name may be "@", "www" or the full name. Proposal: an administrator approves it before it runs.

Inputs: name (required), type (required), content (required), zone_id (required), +5 more.

cloudflare_delete_dns_recordA
Destructive

DESTRUCTIVE: delete a DNS record. name and type must match the record; they are checked first. The deleted record is returned so it can be recreated. Proposal: an administrator approves it before it runs.

Inputs: name (required), type (required), zone_id (required), record_id (required), +1 more.

cloudflare_get_dns_recordA
Read-onlyIdempotent

One DNS record by its ID (from cloudflare_list_dns_records).

Inputs: zone (required), record_id (required).

cloudflare_get_ssl_statusB
Read-onlyIdempotent

A zone's SSL/TLS: encryption mode (off, flexible, full, strict), Always Use HTTPS, minimum TLS version, HSTS, and its certificate packs (universal, advanced or custom) with status, hosts, authority and expiry dates.

Inputs: zone (required).

cloudflare_get_zoneA
Read-onlyIdempotent

One zone by name or ID: ID, status, name servers (and the ones before Cloudflare), account, plan, development mode, page rule quota, and the permissions the token has on it.

Inputs: zone (required).

cloudflare_get_zone_analyticsA
Read-onlyIdempotent

A zone's traffic for the last N days (default 7, at most 30) from the GraphQL Analytics API: requests, cached requests, bandwidth, threats, page views and unique visitors, per day and in total. Older days may be missing on Free plans.

Inputs: zone (required), days.

cloudflare_get_zone_settingsA
Read-onlyIdempotent

A zone's main settings: SSL mode, Always Use HTTPS, minimum TLS, TLS 1.3, HSTS (security_header), automatic HTTPS rewrites, development mode, security level, cache level, browser cache TTL, HTTP/3, IPv6 and similar. full=true returns every setting.

Inputs: zone (required), full.

cloudflare_list_access_appsA
Read-onlyIdempotent

List Cloudflare Zero Trust Access applications in an account: name, type, domain(s), session duration, identity providers and the names of their policies. Read-only; client secrets, keys and policy members are never returned.

Inputs: account_id (required), page, search, per_page.

cloudflare_list_accountsA
Read-onlyIdempotent

List the Cloudflare accounts the token can see (Cititec manages each client in its own account): ID, name, type. Use an account ID to filter cloudflare_list_zones or for cloudflare_list_access_apps.

Inputs: name, page, per_page.

cloudflare_list_dns_recordsA
Read-onlyIdempotent

List DNS records in a zone, optionally by type and name. name is exact ("@" for the apex, "www" or the full name); search matches part of the name. Returns ID, type, name, content, priority, proxied, TTL (1 = automatic), comment.

Inputs: zone (required), name, page, type, +4 more.

cloudflare_list_page_rulesA
Read-onlyIdempotent

A zone's page rules (the older rules: forwarding URLs, cache and SSL overrides per URL pattern) with their targets, actions, priority and status. Newer redirects are in cloudflare_list_redirect_rules.

Inputs: zone (required).

cloudflare_list_redirect_rulesA
Read-onlyIdempotent

A zone's redirect rules (Single Redirects, the http_request_dynamic_redirect phase): description, enabled, the match expression, target URL or expression, status code and whether the query string is kept.

Inputs: zone (required).

cloudflare_list_zonesA
Read-onlyIdempotent

List zones (domains on Cloudflare): ID, name, status, name servers, account, plan. Filter by exact name, by text in the name, by account or by status. To find which client account a domain is in, use name.

Inputs: name, page, search, status, +3 more.

cloudflare_purge_cache_everythingA
Destructive

DESTRUCTIVE: purge EVERYTHING from Cloudflare's cache for a zone. Every visitor's next requests go to the origin, which can overload it. Prefer cloudflare_purge_cache_urls. Proposal: an administrator approves it before it runs.

Inputs: zone_id (required), zone_name (required).

cloudflare_purge_cache_urlsA

Purge up to 30 URLs from Cloudflare's cache in one zone (each URL must be on the zone or a subdomain of it). Proposal: an administrator approves it before it runs.

Inputs: urls (required), zone_id (required), zone_name (required).

cloudflare_set_always_use_httpsA

Turn Always Use HTTPS on or off for a zone (redirects every http:// request to https://). Proposal: an administrator approves it before it runs.

Inputs: enabled (required), zone_id (required), zone_name (required).

cloudflare_set_development_modeA

Turn development mode on or off for a zone (bypasses Cloudflare's cache; turns itself off after 3 hours). Proposal: an administrator approves it before it runs.

Inputs: enabled (required), zone_id (required), zone_name (required).

cloudflare_set_ssl_modeA

Set a zone's SSL/TLS encryption mode: off, flexible (HTTPS to visitors, HTTP to the origin), full (HTTPS to the origin, any certificate) or strict (HTTPS to the origin with a valid certificate). Proposal: an administrator approves it before it runs.

Inputs: mode (required), zone_id (required), zone_name (required).

cloudflare_update_dns_recordA

Change a DNS record: its content, name, TTL, proxied, MX priority or comment (not its type). current_name must be the record's name now; it is checked first. Proposal: an administrator approves it before it runs.

Inputs: zone_id (required), record_id (required), zone_name (required), current_name (required), +6 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 19 tools

    Disambiguation4/5

    Most tools target a clearly distinct resource+action (zones vs DNS records vs page rules vs redirect rules vs cache), and related pairs like purge_cache_urls/purge_cache_everything and list_page_rules/list_redirect_rules are explicitly cross-referenced. The main ambiguity is cloudflare_get_ssl_status versus cloudflare_get_zone_settings, which both return SSL mode, Always Use HTTPS, minimum TLS and HSTS, so an agent could pick either for the same question.

    Naming Consistency5/5

    Every tool follows the same cloudflare_<verb>_<noun> pattern (list_zones, get_dns_record, create_dns_record, set_ssl_mode, purge_cache_everything). Verbs are used consistently by intent: list/get for reads, create/update/delete for CRUD, set for single-setting toggles and purge for cache operations.

    Tool Count4/5

    19 tools is on the heavier side but each maps to a distinct Cloudflare sub-domain (accounts, zones, DNS, SSL, settings, page rules, redirects, Access, analytics, cache). Nothing looks redundant except the partial SSL-status/zone-settings overlap, so the count is justified rather than padded.

    Completeness3/5

    DNS lifecycle is fully covered (list/get/create/update/delete) and cache purge plus key SSL toggles are writable, but page rules and redirect rules are read-only with no create/update/delete, and zone settings can only be changed via three hardcoded toggles rather than a general setter. Account, Access and analytics surfaces are read-only by design, leaving real management gaps for an agent asked to configure a zone.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers