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

# Cloudflare

> Connect Cloudflare with an API token so CloudThinker can review zones, traffic analytics, firewall events, and Workers.

Connect Cloudflare so CloudThinker can list your accounts and zones, summarize HTTP traffic and cache behavior, review firewall events, and look up Cloudflare documentation. CloudThinker uses Cloudflare's hosted MCP server and authenticates with one **API token**, whose permissions decide what CloudThinker can reach.

## Prerequisites

* A Cloudflare account with at least one zone.
* Permission to create API tokens in the [Cloudflare dashboard](https://dash.cloudflare.com/).

## Setup

**1. Create a custom API token**

In the Cloudflare dashboard, go to **My Profile → API Tokens → Create Token**. Under **Create Custom Token**, click **Get started**. Add each permission from the [Required permissions](#required-permissions) table. Each row in the Cloudflare form has three dropdowns, so **Zone → Analytics → Read** means group **Zone**, permission **Analytics**, access **Read**.

**2. Limit the token to the account and zones you need**

Under **Account Resources**, choose **Include → your account**. Under **Zone Resources**, choose **Include → Specific zone** for each zone CloudThinker should see. Use **All zones** only if you want CloudThinker to cover every zone.

**3. Set an expiry, then create and copy the token**

Under **TTL**, set an end date, for example 90 days from today. Leave **Client IP Address Filtering** empty: API calls reach Cloudflare through its hosted MCP server, not from an address you control. Click **Continue to summary → Create Token**. Copy the token now. Cloudflare shows it only once.

> [!NOTE]
>
> Need tokens restricted to known IP addresses? IP whitelist support is available for Enterprise. Contact [support@cloudthinker.io](mailto:support@cloudthinker.io).

To check the token before you paste it:

```bash theme={null}
curl -H "Authorization: Bearer <token>" https://api.cloudflare.com/client/v4/user/tokens/verify
```

**Success state:** the response includes `"status": "active"`.

**4. Add the connection in CloudThinker**

In the sidebar, click **More → Workspace settings → Connections**, select **Cloudflare**, and click **Connect**. Fill in **Alias** (for example `main-account`) and **Description** (for example `Main Cloudflare account, production zones`). Agents read the description to pick the right connection when you have several. Paste the token into **Cloudflare API token**, and click **Connect**.

**Success state:** the connection shows **Connecting** and **Verifying**, then a **Connected** status. Discovery now runs once in the background and spends credits. See [What happens after you connect](https://docs.cloudthinker.io/guide/connections/overview.md#what-happens-after-you-connect).

**5. Set the environment**

Open **Cloudflare** in **More → Workspace settings → Connections**, click the pencil icon on the connection's row, and set **Environment** in **Edit Instance**. It labels the connection for people and agents.

## Connection details

| Field | What to enter |
| - | - |
| **Alias** | Short name for this connection. Blank picks one for you. |
| **Description** | What the account covers. Agents use it to choose between connections. |
| **Cloudflare API token** | The API token you created. CloudThinker sends it as a Bearer token to Cloudflare's hosted MCP server at `https://mcp.cloudflare.com/mcp`, directly from CloudThinker Cloud. |

The data path is CloudThinker Cloud → Cloudflare's [hosted MCP server](https://github.com/cloudflare/mcp-server-cloudflare) → the Cloudflare API, so the token and API responses pass through Cloudflare's own service.

You don't enter an account ID. CloudThinker finds the accounts and zones the token can see. If a token covers several zones and your request matches more than one, CloudThinker asks which zone you mean. You can add more than one Cloudflare connection, for example one token per account.

## Required permissions

Each permission is written as it appears in the Cloudflare form: group → permission → access.

| Permission | Unlocks | Needed |
| - | - | - |
| **Account → Account Settings → Read** | List accounts | Yes |
| **Account → Account Analytics → Read** | Account-level analytics | Yes |
| **Zone → Zone → Read** | List zones and read zone settings | Yes |
| **Zone → DNS → Read** | Read DNS records | Yes |
| **Zone → Analytics → Read** | Traffic analytics and firewall events | Yes |
| **Account → Workers Scripts → Read** | Inspect Workers | Only to inspect Workers |

CloudThinker can only reach what the token allows.

> [!TIP]
>
> Keep the token read-only and scoped to specific zones. There's no fixed list of write actions: **execute** can call any Cloudflare API endpoint, so any edit permission you add to the token, such as **Zone → DNS → Edit**, becomes a change agents can propose. Each call still goes through your approvals.

## Agent capabilities

The connection has three tools. Two run freely. The third calls the Cloudflare API and always goes through [Approvals](https://docs.cloudthinker.io/guide/approvals/overview.md), even for a read, because the same tool can also make changes.

| Tool | What CloudThinker does | Approval |
| - | - | - |
| **docs** | Searches Cloudflare's documentation | No |
| **search** | Finds the right Cloudflare API endpoint for a request | No |
| **execute** | Calls the Cloudflare API: lists accounts and zones, reads zone settings and DNS records, runs GraphQL analytics, reads firewall events, inspects Workers | Yes |

Every change an agent makes goes through your workspace's [Approvals](https://docs.cloudthinker.io/guide/approvals/overview.md) first. On the default **Auto · Rules + AI · Ask me** mode, AI judgment can let a safe change run without asking — and an Allow Rule can too, once CloudThinker turns on [Rule enforcement](https://docs.cloudthinker.io/guide/approvals/rules.md#troubleshooting) for your workspace. Choose **Manual** to approve every change yourself.

Discovery never waits for a person, so it skips any **execute** call that would ask and finds little on Cloudflare. An automation that calls **execute** uses its own Approval mode, **Refuse** by default, so a call that would ask is refused instead.

Built-in query limits keep results small: traffic summaries cover up to 7 days of hourly data for one zone, and firewall reviews cover up to 24 hours and 50 sample events. Firewall output doesn't include client IP addresses.

### Verify the connection

```text theme={null}
List the Cloudflare accounts and zones this token can see
```

The answer comes from the **execute** tool, so it goes through your approvals first. If CloudThinker posts an approval request in the chat, approve it. The answer lists your real account name and zone names.

### Example prompts

```text theme={null}
Summarize HTTP requests, bandwidth, and cache behavior for example.com over the last 7 days
Show which firewall rules blocked or challenged requests on example.com in the last 24 hours
How do I set up a WAF custom rule to rate limit a login path? Use the Cloudflare docs
```

## Troubleshooting

> [accordion] Permission denied
>
> CloudThinker reports `CLOUDFLARE_PERMISSION_DENIED`. The token is missing the read permission for what you asked about. Edit the token in **My Profile → API Tokens**, add the permission, and ask again.

> [accordion] No zones found or zone not found
>
> `CLOUDFLARE_NO_ZONES` means the token lists no zones. `CLOUDFLARE_ZONE_NOT_FOUND` means the zone you named isn't visible to it. Check **Zone Resources** on the token and use the exact zone name.

> [accordion] Nothing happens after I ask a question
>
> Every Cloudflare API call goes through your approvals, and some wait for a person. Check the chat for a pending approval request, or review your [Approval mode](https://docs.cloudthinker.io/guide/approvals/approval-mode.md). If you reject a request, CloudThinker won't retry it.

> [accordion] Analytics come back empty
>
> A new zone or a zone with little traffic may have no analytics yet. Confirm the zone receives traffic through Cloudflare and that the token has **Zone → Analytics → Read**.

> [accordion] Legacy: an older connection shows 'Cloudflare moved to Cloudflare's hosted endpoint'
>
> New connections never hit this. A connection created before the move to Cloudflare's hosted MCP server shows **Error** with this message, and CloudThinker reconnects it on its own. If the status doesn't change, open the connection and click **Retry**. The old Account ID and Enabled Services values are no longer used.

## Security

* **Least privilege** — grant only the permissions the agents need for your use case; start read-only and widen later.
* **Read-only by default** — use read-only credentials unless you want agents to make changes through this connection.
* **Rotate credentials** — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
* **Revoke on offboarding** — remove the credential at the provider when you delete a connection or a teammate leaves.

- **Restrict zones**: limit the token to specific zones rather than all zones to reduce blast radius.
- **Rotate before the TTL ends**: [rotate the token](https://docs.cloudthinker.io/guide/connections/overview.md#rotate-a-credential) before the **TTL** end date you set when you created it.

## Related

> [card] [Approvals](https://docs.cloudthinker.io/guide/approvals/overview.md)
>
> Decide how Cloudflare API calls get approved.

> [card] [Connections overview](https://docs.cloudthinker.io/guide/connections/overview.md)
>
> How connections, testing, and discovery work.


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