Cloudflare Connector

Connect PraisonAI agents to Cloudflare for Workers, DNS, KV, D1, and observability using Cloudflare's official remote MCP server

Connect your PraisonAI agents to Cloudflare to inspect Workers deployments, check observability logs, review KV/D1 resources, and diagnose edge issues through Cloudflare’s official remote MCP server.

SettingValue
Catalog IDcloudflare
Endpointhttps://mcp.cloudflare.com/mcp
TransportStreamable HTTP (Remote)
AuthenticationOAuth 2.1 (browser or --manual)
python
from praisonaiagents import Agent, MCP

agent = Agent(
    name="Edge Ops Assistant",
    instructions="Inspect Cloudflare Workers and logs concisely.",
    tools=MCP(
        "https://mcp.cloudflare.com/mcp",
        oauth=True,
        server_name="cloudflare",
        approval="always",
    ),
)

agent.start("List my active Cloudflare Workers and highlight any recent errors")

The user asks about edge service health; PraisonAI connects to Cloudflare via OAuth 2.1, inspects Workers and logs, and reports anomalies.

Diagram

👤 User

🤖 PraisonAI Agent

🔐 Cloudflare OAuth 2.1

☁️ Cloudflare Remote MCP
mcp.cloudflare.com/mcp

✅ Workers, DNS & Logs


How It Works

PraisonAI discovers Cloudflare’s OAuth 2.1 endpoints automatically, stores your token locally at 0600 in ~/.praisonai/mcp-auth.json, and exposes Cloudflare’s remote tools across Python, CLI, and Dashboard.

Diagram
PraisonAI AgentCloudflare MCP Servermcp-auth.jsonCloudflare OAuth 2.1praisonai CLIUserPraisonAI AgentCloudflare MCP Servermcp-auth.jsonCloudflare OAuth 2.1praisonai CLIUserpraisonai connectors add cloudflare –authRun OAuth 2.1 PKCE consentApprove Cloudflare account accessSave OAuth token (0600)Check Workers status and logsLoad cached tokenCall Cloudflare MCP toolsWorker metadata and metricsDiagnostics summary

Step-by-Step Setup

  1. Prerequisites
    • A Cloudflare account with Workers, Pages, DNS, or storage resources you want to manage
  2. Install PraisonAI with MCP support
    bash
    pip install "praisonai[mcp]"
  3. Add and authenticate Cloudflare

    CLI (Interactive OAuth)

    bash
    praisonai connectors add cloudflare --auth

    Headless / SSH (–manual)

    bash
    praisonai connectors add cloudflare --auth --manual

    PraisonAI Dashboard

    Enable catalog connectors in your PraisonAIUI config.yaml:

    yaml
    mcp:
      enabled: true
      allow:
        catalog: true

    Run praisonai dashboard, open Connectors / MCP, and click Connect on Cloudflare.

  4. Verify and list available tools
    bash
    praisonai mcp sync cloudflare
  5. Run your agent
    python
    from praisonaiagents import Agent, MCP
    
    agent = Agent(
        name="Cloudflare Inspector",
        instructions="Inspect Cloudflare Workers and ask before making any configuration changes.",
        tools=MCP(
            "https://mcp.cloudflare.com/mcp",
            oauth=True,
            server_name="cloudflare",
            approval="always",
        ),
    )
    
    agent.start("List all Cloudflare accounts and Workers I have access to")

Scope Tools for Safety


Common Workflows

  • Worker Error Investigation: "Check recent error logs for the api-gateway Worker and summarize the top failure codes."
  • Resource Inventory: "List all D1 databases and KV namespaces in my staging Cloudflare account."

Troubleshooting

SymptomCauseFix
401 Unauthorized on praisonai connectors test cloudflareconnectors test does not attach stored OAuth tokensVerify with praisonai mcp sync cloudflare
Multiple Cloudflare accounts returnedAccount not specified in promptMention the exact Cloudflare account name or ID in instructions
Browser callback times out over SSHLoopback port unreachable remotelyRun praisonai connectors auth cloudflare --manual

Best Practices

Pin staging vs production account IDs in instructions

Explicitly tell your agent which Cloudflare account ID is staging vs production so it never inspects or mutates the wrong environment.

Keep approval='always' on infrastructure connectors

Require human approval before any DNS, firewall, KV write, or Worker redeployment call executes.

Refresh tokens cleanly after role changes

Run praisonai connectors logout cloudflare --yes then praisonai connectors auth cloudflare whenever your Cloudflare account permissions change.


Related