Skip to content

Strands Cloudflare: Universal Cloudflare API 🌩️

PyPI

Dynamically access the entire Cloudflare API through a single tool using the official cloudflare-python SDK.

Installation

pip install strands-cloudflare

Setup

# Option 1: API Token (recommended)
export CLOUDFLARE_API_TOKEN="your-api-token"

# Option 2: API Key + Email
export CLOUDFLARE_API_KEY="your-api-key"
export CLOUDFLARE_EMAIL="[email protected]"

# Optional defaults
export CLOUDFLARE_ACCOUNT_ID="your-account-id"
export CLOUDFLARE_ZONE_ID="your-zone-id"

Quick Start

from strands import Agent
from strands_cloudflare import use_cloudflare

agent = Agent(tools=[use_cloudflare])
agent("List all my Cloudflare zones")

How It Works

Specify service, operation, and parameters:

Parameter Description
service SDK path (e.g., zones, dns.records, workers.scripts)
operation Method (e.g., list, get, create, delete)
params JSON parameters
account_id Account ID (optional)
zone_id Zone ID (optional)

Service Discovery

# List all services
use_cloudflare(service="_", operation="_")

# List operations for a service
use_cloudflare(service="dns.records", operation="_")

Examples

Zones

# List all zones
use_cloudflare(service="zones", operation="list")

# Get specific zone
use_cloudflare(service="zones", operation="get", zone_id="abc123")

DNS Records

# List DNS records
use_cloudflare(service="dns.records", operation="list", zone_id="abc123")

# Create DNS record
use_cloudflare(
    service="dns.records",
    operation="create",
    zone_id="abc123",
    params='{"type": "A", "name": "www", "content": "192.0.2.1", "proxied": true}'
)

# Update DNS record
use_cloudflare(
    service="dns.records",
    operation="update",
    zone_id="abc123",
    params='{"dns_record_id": "record-id", "type": "A", "name": "www", "content": "192.0.2.2"}'
)

# Delete DNS record
use_cloudflare(
    service="dns.records",
    operation="delete",
    zone_id="abc123",
    params='{"dns_record_id": "record-id"}'
)

Workers

# List Workers scripts
use_cloudflare(service="workers.scripts", operation="list", account_id="xyz")

# Get Worker script
use_cloudflare(
    service="workers.scripts",
    operation="get",
    account_id="xyz",
    params='{"script_name": "my-worker"}'
)

Pages

# List Pages projects
use_cloudflare(service="pages.projects", operation="list", account_id="xyz")

Available Services

Service Description
zones Zone management
dns.records DNS record management
workers.scripts Workers scripts
pages.projects Pages projects
firewall.rules Firewall rules
ssl.certificates SSL certificates
cache Cache management
analytics Analytics data
+ many more Full Cloudflare API

All of Cloudflare, in natural language. 🌩️