Skip to main content

Universal Cloudflare tool for Strands Agents - manage Zones, DNS, Workers, KV, R2, D1, Pages, AI, Tunnels and 25+ more services

Project description

strands-cloudflare

PyPI version License

A comprehensive Cloudflare tool for Strands Agents. Access 70+ Cloudflare API actions from a single tool.

Installation

pip install strands-cloudflare

Quick Start

from strands import Agent
from strands_cloudflare import use_cloudflare

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

Configuration

Set your Cloudflare credentials as environment variables:

# 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="your-email@example.com"

# Optional
export CLOUDFLARE_ACCOUNT_ID="your-account-id"  # Required for Workers, KV, D1, R2, Pages
export CLOUDFLARE_ZONE_ID="your-zone-id"        # Default zone for DNS operations

Supported Services (70+ Actions)

Category Actions
Zones list_zones, get_zone, create_zone, delete_zone, zone_settings, update_zone_setting
DNS list_dns_records, get_dns_record, create_dns_record, update_dns_record, delete_dns_record, export_dns
Workers list_workers, get_worker, deploy_worker, delete_worker, list_worker_routes, create_worker_route
KV list_kv_namespaces, create_kv_namespace, delete_kv_namespace, list_kv_keys, kv_get, kv_put, kv_delete
D1 list_d1_databases, create_d1_database, delete_d1_database, d1_query
R2 list_r2_buckets, create_r2_bucket, delete_r2_bucket, r2_list_objects, r2_get_object, r2_put_object, r2_delete_object
Pages list_pages_projects, get_pages_project, create_pages_project, delete_pages_project, list_pages_deployments
Workers AI list_ai_models, ai_text_generation, ai_text_embedding, ai_translation, ai_summarization
Tunnels list_tunnels, get_tunnel, create_tunnel, delete_tunnel, get_tunnel_token, list_tunnel_connections, get_tunnel_config, update_tunnel_config
Firewall list_firewall_rules, create_firewall_rule, delete_firewall_rule
Access list_access_apps, list_access_groups
Cache purge_cache_all, purge_cache_urls, purge_cache_tags, get_cache_settings
SSL/TLS get_ssl_settings, update_ssl_settings, list_ssl_certificates
Page Rules list_page_rules, create_page_rule, delete_page_rule
Analytics get_zone_analytics, get_dns_analytics, get_analytics
Load Balancing list_load_balancers, list_lb_pools, list_lb_monitors
Rate Limiting list_rate_limits, create_rate_limit
Email get_email_routing, list_email_rules
Queues list_queues, create_queue
Hyperdrive list_hyperdrives, create_hyperdrive
Vectorize list_vectorize_indexes, create_vectorize_index
Durable Objects list_durable_objects
Images/Stream list_images, list_stream_videos
Account list_accounts, get_account, list_account_members
User get_user
Meta list_actions, describe, api_call

Usage Examples

List Zones

use_cloudflare(action="list_zones")

Create DNS Record

use_cloudflare(
    action="create_dns_record",
    zone_id="your-zone-id",
    record_type="A",
    name="www",
    content="192.0.2.1",
    proxied=True
)

Deploy Worker

use_cloudflare(
    action="deploy_worker",
    worker_name="my-worker",
    script='export default { fetch(request) { return new Response("Hello!") } }'
)

Query D1 Database

use_cloudflare(
    action="d1_query",
    database_id="your-db-id",
    sql="SELECT * FROM users LIMIT 10"
)

Purge Cache

use_cloudflare(
    action="purge_cache_all",
    zone_id="your-zone-id"
)

Create Tunnel

use_cloudflare(
    action="create_tunnel",
    tunnel_name="my-tunnel"
)

Workers AI Text Generation

use_cloudflare(
    action="ai_text_generation",
    model="@cf/meta/llama-2-7b-chat-int8",
    prompt="What is the meaning of life?"
)

Generic API Call

use_cloudflare(
    action="api_call",
    method="GET",
    path="/zones"
)

With Strands Agent

from strands import Agent
from strands_cloudflare import use_cloudflare

agent = Agent(tools=[use_cloudflare])

# Natural language queries
agent("Create a DNS A record for api.example.com pointing to 203.0.113.50")
agent("Deploy a hello world worker named greeting-worker")
agent("Purge the cache for my main zone")
agent("List all my Cloudflare tunnels")

Response Format

All actions return a consistent response format:

{
    "status": "success",  # or "error"
    "content": [{"text": "JSON response data"}],
    "action": "list_zones",
    "ms": 234  # Response time in milliseconds
}

Security

  • API tokens/keys are never logged or included in responses
  • Sensitive data is automatically redacted from output
  • Use API tokens with minimal required permissions

Requirements

  • Python 3.9+
  • strands-agents >= 0.1.0
  • requests >= 2.25.0

License

Apache License 2.0

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strands_cloudflare-0.1.0.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strands_cloudflare-0.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file strands_cloudflare-0.1.0.tar.gz.

File metadata

  • Download URL: strands_cloudflare-0.1.0.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for strands_cloudflare-0.1.0.tar.gz
Algorithm Hash digest
SHA256 93a9664d3a700544299fd4ee276731335c2bd907ad28ed13b46bafef20dc7db9
MD5 c9254c486221225af0bb1dbb61e2855e
BLAKE2b-256 106e64786db0cf303713116c697bb127b3a9789c1c855d054350b1ac13e1f6d6

See more details on using hashes here.

File details

Details for the file strands_cloudflare-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for strands_cloudflare-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70e0edef2af4454a0955437d03549bed160d957a1bbcac00a3084383384107ba
MD5 f44ccb1fdf62c7a23ecaf5ec28ad918f
BLAKE2b-256 383a59c2436b560f3bd59bf3edee860bfc728753153ceea83bfb3927cf6108a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page