From e0ca07a32b1a6118097f70a855d169fd87c0c644 Mon Sep 17 00:00:00 2001 From: Jaksenc Date: Tue, 12 May 2026 12:46:07 -0400 Subject: [PATCH 1/2] Add Claude Code connection guide --- README.md | 4 ++ docs/connection-guides/claude-code.md | 66 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 docs/connection-guides/claude-code.md diff --git a/README.md b/README.md index 365764a..bb40700 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ MCP URL: `https://mcp.cloudflare.com/mcp` +Connection guides: + +- [Claude Code](docs/connection-guides/claude-code.md) + ### Option 1: OAuth (Recommended) Just connect to the MCP server URL - you'll be redirected to Cloudflare to authorize and select permissions. diff --git a/docs/connection-guides/claude-code.md b/docs/connection-guides/claude-code.md new file mode 100644 index 0000000..2524904 --- /dev/null +++ b/docs/connection-guides/claude-code.md @@ -0,0 +1,66 @@ +# Claude Code + +Add the Cloudflare MCP server to Claude Code with a `.mcp.json` file. + +## OAuth + +For the hosted Cloudflare MCP server, add this configuration: + +```json +{ + "mcpServers": { + "cloudflare-api": { + "type": "http", + "url": "https://mcp.cloudflare.com/mcp" + } + } +} +``` + +Restart Claude Code after saving the file. Claude Code will connect over HTTP +and Cloudflare will prompt you to authorize access with OAuth. + +## API Token + +For automation or CI/CD workflows, create a +[Cloudflare API token](https://dash.cloudflare.com/profile/api-tokens) with the +permissions your agent needs, then pass it as a bearer token: + +```json +{ + "mcpServers": { + "cloudflare-api": { + "type": "http", + "url": "https://mcp.cloudflare.com/mcp", + "headers": { + "Authorization": "Bearer ${CLOUDFLARE_API_TOKEN}" + } + } + } +} +``` + +Both user tokens and account tokens are supported. For account tokens, include +the **Account Resources : Read** permission so the server can auto-detect your +account ID. Claude Code expands environment variables in `.mcp.json`, so keep +the token in your shell environment instead of committing the value to the file. + +## Disable Code Mode + +If you need each Cloudflare API endpoint exposed as an individual tool, add +`?codemode=false` to the URL: + +```json +{ + "mcpServers": { + "cloudflare-api": { + "type": "http", + "url": "https://mcp.cloudflare.com/mcp?codemode=false" + } + } +} +``` + +Only disable code mode when needed. It significantly increases the token cost +because the server registers thousands of endpoint-specific tools instead of +the compact code mode tools. From 1c9be3f789013fce3ed448cd7a68510f7d7baa85 Mon Sep 17 00:00:00 2001 From: Matt Carey Date: Thu, 2 Jul 2026 17:56:52 +0100 Subject: [PATCH 2/2] docs: lead with claude mcp add per current Claude Code docs --- docs/connection-guides/claude-code.md | 66 +++++++++++---------------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/docs/connection-guides/claude-code.md b/docs/connection-guides/claude-code.md index 2524904..1806049 100644 --- a/docs/connection-guides/claude-code.md +++ b/docs/connection-guides/claude-code.md @@ -1,66 +1,52 @@ # Claude Code -Add the Cloudflare MCP server to Claude Code with a `.mcp.json` file. +Connect [Claude Code](https://code.claude.com/docs/en/overview) to the Cloudflare MCP server with one command: -## OAuth - -For the hosted Cloudflare MCP server, add this configuration: - -```json -{ - "mcpServers": { - "cloudflare-api": { - "type": "http", - "url": "https://mcp.cloudflare.com/mcp" - } - } -} +```bash +claude mcp add --transport http cloudflare-api https://mcp.cloudflare.com/mcp ``` -Restart Claude Code after saving the file. Claude Code will connect over HTTP -and Cloudflare will prompt you to authorize access with OAuth. +Then run `/mcp` inside Claude Code to sign in. Cloudflare will prompt you to +authorize access and select permissions with OAuth. ## API Token -For automation or CI/CD workflows, create a -[Cloudflare API token](https://dash.cloudflare.com/profile/api-tokens) with the -permissions your agent needs, then pass it as a bearer token: +For CI/CD and automation, skip OAuth and pass a +[Cloudflare API token](https://dash.cloudflare.com/profile/api-tokens) as a +bearer token: -```json -{ - "mcpServers": { - "cloudflare-api": { - "type": "http", - "url": "https://mcp.cloudflare.com/mcp", - "headers": { - "Authorization": "Bearer ${CLOUDFLARE_API_TOKEN}" - } - } - } -} +```bash +claude mcp add --transport http cloudflare-api https://mcp.cloudflare.com/mcp \ + --header "Authorization: Bearer YOUR_CLOUDFLARE_API_TOKEN" ``` Both user tokens and account tokens are supported. For account tokens, include the **Account Resources : Read** permission so the server can auto-detect your -account ID. Claude Code expands environment variables in `.mcp.json`, so keep -the token in your shell environment instead of committing the value to the file. +account ID. -## Disable Code Mode +## Share with Your Team -If you need each Cloudflare API endpoint exposed as an individual tool, add -`?codemode=false` to the URL: +To check the server into your repo, add a `.mcp.json` file at the project root +(or run the command above with `--scope project`): ```json { "mcpServers": { "cloudflare-api": { "type": "http", - "url": "https://mcp.cloudflare.com/mcp?codemode=false" + "url": "https://mcp.cloudflare.com/mcp" } } } ``` -Only disable code mode when needed. It significantly increases the token cost -because the server registers thousands of endpoint-specific tools instead of -the compact code mode tools. +Claude Code expands environment variables in `.mcp.json`, so an API token +header can reference `${CLOUDFLARE_API_TOKEN}` instead of committing the value +to the file. + +## Disable Code Mode + +To expose each Cloudflare API endpoint as an individual tool instead of the +compact code mode tools, add `?codemode=false` to the URL. This registers +~2,500 endpoint-specific tools and uses far more context, so only disable code +mode when you need it.