Skip to main content

MCP Cloudflare CrunchTools

A secure MCP (Model Context Protocol) server for Cloudflare DNS, Transform Rules, Page Rules, and cache management.

Overview

This MCP server is designed to be:

  • Secure by default - Threat modeling, input validation, and token protection
  • No third-party services - Runs locally via stdio, your API token never leaves your machine
  • Cross-platform - Works on Linux, macOS, and Windows
  • Automatically updated - GitHub Actions monitor for CVEs and update dependencies
  • Containerized - Available at quay.io/crunchtools/mcp-cloudflare built on Hummingbird Python base image

Naming Convention

Component Name
GitHub repo crunchtools/mcp-cloudflare
Container quay.io/crunchtools/mcp-cloudflare
Python package (PyPI) mcp-cloudflare-crunchtools
CLI command mcp-cloudflare-crunchtools
Module import mcp_cloudflare_crunchtools

Why Hummingbird?

The container image is built on the Hummingbird Python base image from Project Hummingbird, which provides:

  • Minimal CVE exposure - Hummingbird images are built with a minimal package set, dramatically reducing the attack surface compared to general-purpose images
  • Regular updates - Security patches are applied promptly, keeping CVE counts low
  • Optimized for Python - Pre-configured Python environment with uv package manager for fast, reproducible builds
  • Production-ready - Designed for production workloads with proper signal handling and non-root user defaults

This means your MCP server runs in a hardened environment with fewer vulnerabilities than typical Python container images

Features

Zone Management (2 tools)

  • list_zones - List all zones accessible by your API token
  • get_zone - Get zone details by ID or domain name

DNS Records (5 tools)

  • list_dns_records - List DNS records with filtering
  • get_dns_record - Get a single DNS record
  • create_dns_record - Create A, AAAA, CNAME, MX, TXT, NS, SRV, CAA records
  • update_dns_record - Update existing records
  • delete_dns_record - Delete records

Transform Rules (6 tools)

  • list_request_header_rules / set_request_header_rules - Modify request headers
  • list_response_header_rules / set_response_header_rules - Modify response headers
  • list_url_rewrite_rules / set_url_rewrite_rules - URL path/query rewrites

Page Rules (4 tools)

  • list_page_rules - List all page rules
  • create_page_rule - Create redirects, cache settings, SSL modes
  • update_page_rule - Modify existing rules
  • delete_page_rule - Remove rules

Cache Management (1 tool)

  • purge_cache - Purge by URL, tag, host, prefix, or everything

Installation

uvx mcp-cloudflare-crunchtools

With pip

pip install mcp-cloudflare-crunchtools

With Container

podman run -e CLOUDFLARE_API_TOKEN=your_token \
    quay.io/crunchtools/mcp-cloudflare

Configuration

Creating a Cloudflare API Token

  1. Navigate to API Tokens

  2. Configure Token Name

    • Enter: mcp-cloudflare-crunchtools
  3. Configure Permissions

    The Permissions section has three dropdowns per row:

    • First dropdown: Resource type (Account or Zone)
    • Second dropdown: Specific permission category
    • Third dropdown: Access level (Read or Edit)

    Click "+ Add more" to add each permission row. For full management, add:

    Resource Permission Access
    Zone Zone Read
    Zone DNS Edit
    Zone Page Rules Edit
    Zone Transform Rules Edit
    Zone Cache Purge Purge
  4. Configure Zone Resources

    • First dropdown: Select "Include"
    • Second dropdown: Select "All zones" or "Specific zone"
  5. Configure Client IP Address Filtering (Optional)

    • Click "Use my IP" button to restrict token to your current IP
  6. Create and Copy Token

    • Click "Continue to summary" → "Create Token"
    • IMPORTANT: Copy the token immediately - it's only shown once!

Add to Claude Code

claude mcp add mcp-cloudflare-crunchtools \
    --env CLOUDFLARE_API_TOKEN=your_token_here \
    -- uvx mcp-cloudflare-crunchtools

Or for the container version:

claude mcp add mcp-cloudflare-crunchtools \
    --env CLOUDFLARE_API_TOKEN=your_token_here \
    -- podman run -i --rm -e CLOUDFLARE_API_TOKEN quay.io/crunchtools/mcp-cloudflare

Permission Sets by Use Case

Read-Only (viewing only)

Resource Permission Access
Zone Zone Read
Zone DNS Read

DNS Management Only

Resource Permission Access
Zone Zone Read
Zone DNS Edit

Full Management (all features)

Resource Permission Access
Zone Zone Read
Zone DNS Edit
Zone Page Rules Edit
Zone Transform Rules Edit
Zone Cache Purge Purge

Usage Examples

List Your Zones

User: List my Cloudflare zones
Assistant: [calls list_zones]

Create a DNS Record

User: Create an A record for www.example.com pointing to 192.168.1.1
Assistant: [calls create_dns_record with type=A, name=www, content=192.168.1.1]

Add Security Headers

User: Add X-Content-Type-Options: nosniff to all responses for zone abc123...
Assistant: [calls set_response_header_rules with appropriate rule]

Purge Cache

User: Purge the cache for https://example.com/styles.css
Assistant: [calls purge_cache with files=["https://example.com/styles.css"]]

Security

This server was designed with security as a primary concern. See SECURITY.md for:

  • Threat model and attack vectors
  • Defense in depth architecture
  • Token handling best practices
  • Input validation rules
  • Audit logging

Key Security Features

  1. Token Protection

    • Stored as SecretStr (never accidentally logged)
    • Environment variable only (never in files or args)
    • Sanitized from all error messages
  2. Input Validation

    • Pydantic models for all inputs
    • Allowlist for record types, actions
    • Strict format validation for IDs
  3. API Hardening

    • Hardcoded API base URL (prevents SSRF)
    • TLS certificate validation
    • Request timeouts
    • Response size limits
  4. Automated CVE Scanning

    • GitHub Actions scan dependencies weekly
    • Automatic PRs for security updates
    • Dependabot alerts enabled

Development

Setup

git clone https://github.com/crunchtools/mcp-cloudflare.git
cd mcp-cloudflare
uv sync

Run Tests

uv run pytest

Lint and Type Check

uv run ruff check src tests
uv run mypy src

Build Container

podman build -t mcp-cloudflare .

License

AGPL-3.0-or-later

Contributing

Contributions welcome! Please read SECURITY.md before submitting security-related changes.

Metadata

Release files for mcp-cloudflare-crunchtools 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-cloudflare-crunchtools 0.6.0
File Size Uploaded
mcp_cloudflare_crunchtools-0.6.0.tar.gz 175.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-cloudflare-crunchtools 0.6.0
File Interpreter ABI Platform
mcp_cloudflare_crunchtools-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 215.6 kB

Release files / mcp_cloudflare_crunchtools-0.6.0.tar.gz

Download URL mcp_cloudflare_crunchtools-0.6.0.tar.gz
Size 175.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6e44e6af2900ca461629aa7d77970bbfef839cdf61b692364e42e8cfb44872e2
BLAKE2b-256 checksum
How to use checksums
563d035afdc5d9c3bdd4d2270f9b77caf37ad269bb5c98843e47a1cee2844ee9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / mcp_cloudflare_crunchtools-0.6.0-py3-none-any.whl

Download URL mcp_cloudflare_crunchtools-0.6.0-py3-none-any.whl
Size 40.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8780a9e49fe8ddf4d3df9d097294547f16c4fdf2f78c5fbc656e8696aea5ff1
BLAKE2b-256 checksum
How to use checksums
1941a59d3d71e3829b12b3d2da3d7741b4823f3d80998017a2351bbdf25730b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

This release

0.6.0 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page