Cloudflare MCP Server & CLI

Cloudflare MCP server and CLI for Codex and AI agents. 29 tools for current DNS, cache, zone settings, Rulesets, Worker metadata and read-only analytics, with private accounts and explicit operation approval. One shared implementation supplies both binaries and a desktop bundle.
Built and maintained by Navid Moazzez. Built on Slipway, which turns one definition of each tool into the MCP server and the CLI. The complete guide is on navid.me.
The terminal illustrates real command names and approval flow. It is not a recording of a provider account run. Cloudflare already has official CLI and hosted MCP products; their current schemas, approval policies and supported workflows are compared below.
Requires Node 22+ and eligible Cloudflare API access for account operations. Validation: fixture tests, schema validation and protocol/artifact discovery are separate from provider-account outcomes and desktop GUI outcomes, which remain unverified. Section 7 has the measured token costs; no success rate is invented.
Two ways to use it
Command line
npm install -g @thenavidm/cloudflare-mcp-cli@latest
cloudflare-cli tools
cloudflare-cli list-zones --per-page 10 --agent
cloudflare-cli schema create-dns-record
cloudflare-cli create-dns-record --zone-id YOUR_ZONE_ID --payload-file /absolute/private/approved-dns.json --account work --confirm --agent
MCP server, for your AI app
codex mcp add cloudflare -- npx -y @thenavidm/cloudflare-mcp-cli@latest
Configure private credentials first. Ask: “Read DNS for this exact zone; do not change any records.” Full setup is in INSTALL.md.
Which one
| Where you work | Surface |
|---|
| Codex or shell agent | Shared CLI, local MCP or both |
| Desktop chat | Compatible local MCP or desktop bundle |
| Scripts / CI | CLI or MCP client |
| Remote-only client / broad API | Official Cloudflare hosted MCP / cf |
| Workers deployment | Official Wrangler / cf |
Features
| Capability | CLI | MCP |
|---|
| Zone/DNS reads | list-zones / list-dns-records | list_zones / list_dns_records |
| Explicit DNS changes | create-dns-record / update-dns-record | create_dns_record / update_dns_record |
| Exact DNS review/apply | preview-dns-batch / apply-dns-batch | preview_dns_batch / apply_dns_batch |
| Rulesets and settings | get-zone-ruleset / get-zone-setting | get_zone_ruleset / get_zone_setting |
| Bounded reads / analytics | query-pages / analytics-query | query_pages / analytics_query |
| Local schemas / previews | get-operation-schema / preview-operation | get_operation_schema / preview_operation |
| Profiles and policy | list-accounts / --account / --confirm | list_accounts / account / confirm |
Contents
1. What you can ask it
- Read the intended zone's DNS records without changing anything.
- Inspect the exact native schema for an A, AAAA, TXT, MX or other supported DNS request.
- Preview a small reviewed DNS batch and submit only the same approved zone/profile/body.
- Apply one explicit DNS edit or deletion after inspecting its record ID and content.
- Read the selected zone setting, then change only the approved value.
- Inspect current Rulesets and the selected phase entrypoint before approving a Ruleset change.
- Purge only the requested cache targets after confirmation.
- Query an eligible analytics dataset for an explicit time window without mutations.
Actual credential-free stdio discovery supplies 29 tools: 18 reads and 11 confirmation-gated mutations. Twenty-two native operations use a pinned, reviewed current REST schema; seven helpers provide local profile/schema/preview, bounded reads, DNS review/apply and query-only analytics. This is a focused management surface. It does not deploy Workers, expose an unrestricted raw API request or implement every Cloudflare product.
2. Quick install
npm install -g @thenavidm/cloudflare-mcp-cli@latest
cloudflare-cli --version
cloudflare-cli tools
cloudflare-cli schema create-dns-record
cloudflare-cli login
Requires Node 22+ for manual installs. Configure private tokens before provider calls. Discovery and local previews work without provider authentication. See INSTALL.md for macOS, Windows, Linux, every supported local client, Docker and desktop extension setup.
3. Set up Cloudflare access
Private API tokens and resource access
- Choose the intended Cloudflare user/account and zone. Create a least-privilege API token through My Profile > API Tokens, or Manage account > Account API tokens for an account-owned token.
- Choose only the permissions needed below and restrict account/zone resources. Check optional expiry and IP filters. Save the secret privately outside every repository; never use the Global API Key with this Bearer-only package.
- Configure CLOUDFLARE_TOKEN_FILE as an absolute token-only file, or privately set CLOUDFLARE_API_TOKEN. Optional CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_ZONE_ID supply input defaults. A default does not restrict token permissions.
- Run cloudflare-cli doctor for local configuration checks. Deliberately run doctor --network to verify token status: user tokens use GET /user/tokens/verify; account-owned tokens need CLOUDFLARE_TOKEN_KIND=account and a private account ID, using GET /accounts/{account_id}/tokens/verify. Only an active result is accepted; token IDs/status bodies are not printed.
- Read the exact zone and DNS records, inspect the complete current input schema, preview the intended change locally and approve only the chosen request. A local preview does not verify provider permissions, conflicts or current remote state.
Requests use Authorization: Bearer on the fixed https://api.cloudflare.com/client/v4 origin. Token-kind selection changes the diagnostic route, not ordinary authorization or resource access. The wrapper does not implement OAuth login, refresh, saved official cf sessions, automatic .env loading or global CLI config ingestion. login prints instructions; it neither opens consent nor saves credentials.
User tokens inherit permitted user access. Account-owned tokens act as service principals; creation requires the provider's token-provisioning capability or Super Administrator role and grants cannot exceed the creator's permissions. Some products still have compatibility restrictions; verify the exact operation in the account-token compatibility documentation.