> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

| Setting | Value |
| - | - |
| **Catalog ID** | `cloudflare` |
| **Endpoint** | `https://mcp.cloudflare.com/mcp` |
| **Transport** | Streamable HTTP (Remote) |
| **Authentication** | OAuth 2.1 (browser or `--manual`) |

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    User["👤 User"] --> Agent["🤖 PraisonAI Agent"]
    Agent --> Auth["🔐 Cloudflare OAuth 2.1"]
    Auth --> CF["☁️ Cloudflare Remote MCP<br/>mcp.cloudflare.com/mcp"]
    CF --> Result["✅ Workers, DNS & Logs"]

    classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef auth fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef ok fill:#10B981,stroke:#7C90A0,color:#fff

    class User input
    class Agent agent
    class Auth auth
    class CF,Result ok
```

***

## 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.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant CLI as praisonai CLI
    participant CFAuth as Cloudflare OAuth 2.1
    participant Store as mcp-auth.json
    participant CFMCP as Cloudflare MCP Server
    participant Agent as PraisonAI Agent

    User->>CLI: praisonai connectors add cloudflare --auth
    CLI->>CFAuth: Run OAuth 2.1 PKCE consent
    CFAuth-->>User: Approve Cloudflare account access
    CFAuth-->>Store: Save OAuth token (0600)
    User->>Agent: Check Workers status and logs
    Agent->>Store: Load cached token
    Agent->>CFMCP: Call Cloudflare MCP tools
    CFMCP-->>Agent: Worker metadata and metrics
    Agent-->>User: Diagnostics 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install "praisonai[mcp]"
```

**3. Add and authenticate Cloudflare**

> [tab] CLI (Interactive OAuth)
>
> ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> praisonai connectors add cloudflare --auth
> ```

> [tab] Headless / SSH (--manual)
>
> ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> praisonai connectors add cloudflare --auth --manual
> ```

> [tab] PraisonAI Dashboard
>
> Enable catalog connectors in your PraisonAIUI `config.yaml`:
>
> ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> mcp:
>   enabled: true
>   allow:
>     catalog: true
> ```
>
> Run `praisonai dashboard`, open **Connectors / MCP**, and click **Connect** on **Cloudflare**.

**4. Verify and list available tools**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai mcp sync cloudflare
```

**5. Run your agent**

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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

> [!WARNING]
>
> DNS, WAF, and Worker deployment changes affect live production traffic immediately. Always inspect tool names with `praisonai mcp sync cloudflare`, restrict read-only agents with `--allow`, and set `approval="always"` for write actions.

***

## 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

| Symptom | Cause | Fix |
| - | - | - |
| `401 Unauthorized` on `praisonai connectors test cloudflare` | `connectors test` does not attach stored OAuth tokens | Verify with `praisonai mcp sync cloudflare` |
| Multiple Cloudflare accounts returned | Account not specified in prompt | Mention the exact Cloudflare account name or ID in `instructions` |
| Browser callback times out over SSH | Loopback port unreachable remotely | Run `praisonai connectors auth cloudflare --manual` |

***

## Best Practices

> [accordion] 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.

> [accordion] Keep approval='always' on infrastructure connectors
>
> Require human approval before any DNS, firewall, KV write, or Worker redeployment call executes.

> [accordion] Refresh tokens cleanly after role changes
>
> Run `praisonai connectors logout cloudflare --yes` then `praisonai connectors auth cloudflare` whenever your Cloudflare account permissions change.

***

## Related

> [card] [List of Connectors](https://praison.ai/docs/features/connectors-list.md)
>
> Browse all popular connectors and step-by-step guides

> [card] [Vercel Connector](https://praison.ai/docs/mcp/vercel.md)
>
> Inspect frontend deployments and build logs on Vercel

> [card] [Remote MCP Connectors](https://praison.ai/docs/features/connectors.md)
>
> CLI commands, --manual mode, and Dashboard reference

> [card] [MCP OAuth Authentication](https://praison.ai/docs/mcp/mcp-oauth.md)
>
> OAuth 2.1 PKCE flow and token storage


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.