The Cloudflare MCP connector routes your AI agent's tool calls to Cloudflare's own MCP server through Scalekit. Each user signs in to Cloudflare once, and Scalekit stores and refreshes their tokens, so your agent never handles credentials. It comes with 4 tools.
- Tools
- 4
- What they doRead · write · destructive
- 3 · 1 · 03 read1 write0 destructive
- Users sign in with
- OAuth
- OAuth app
- Scalekit's or your own
Setup
Install the SDK
Terminal window npm install @scalekit-sdk/node dotenvTerminal window pip install scalekit-sdk-python python-dotenvSet your credentials
Add your Scalekit credentials to your
.envfile. Find values in app.scalekit.com > Developers > API Credentials..env SCALEKIT_ENVIRONMENT_URL=<your-environment-url>SCALEKIT_CLIENT_ID=<your-client-id>SCALEKIT_CLIENT_SECRET=<your-client-secret>Create the Cloudflare MCP connection
In AgentKit > Connections, create a Cloudflare MCP connection. The name you give it is the
connection_nameyour code passes. See Configure connections.Scalekit credentials are available for Cloudflare, so you don't need to register an OAuth app.
Authorize a user and make your first call
quickstart.mts import { ScalekitClient } from '@scalekit-sdk/node'import 'dotenv/config'import { createInterface } from 'node:readline/promises'const scalekit = new ScalekitClient(process.env.SCALEKIT_ENVIRONMENT_URL,process.env.SCALEKIT_CLIENT_ID,process.env.SCALEKIT_CLIENT_SECRET,)const actions = scalekit.actionsconst connector = 'cloudfaremcp'const identifier = 'user_123'// Generate an authorization link for the userconst { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })console.log('Authorize Cloudflare MCP:', link)const rl = createInterface({ input: process.stdin, output: process.stdout })await rl.question('Press Enter after authorizing...')rl.close()// Make your first callconst result = await actions.executeTool({connector,identifier,toolName: 'cloudfaremcp_whoami',toolInput: {},})console.log(result)Terminal window npx tsx quickstart.mtsquickstart.py import osfrom scalekit import ScalekitClientfrom dotenv import load_dotenvload_dotenv()scalekit_client = ScalekitClient(env_url=os.getenv("SCALEKIT_ENVIRONMENT_URL"),client_id=os.getenv("SCALEKIT_CLIENT_ID"),client_secret=os.getenv("SCALEKIT_CLIENT_SECRET"),)actions = scalekit_client.actionsconnection_name = "cloudfaremcp"identifier = "user_123"# Generate an authorization link for the userlink_response = actions.get_authorization_link(connection_name=connection_name,identifier=identifier,)print("Authorize Cloudflare MCP:", link_response.link)input("Press Enter after authorizing...")# Make your first callresult = actions.execute_tool(tool_input={},tool_name="cloudfaremcp_whoami",connection_name=connection_name,identifier=identifier,)print(result)Terminal window python quickstart.pyEach user signs in once. See Authorize a user for the full flow and statuses.
Tools
Pass the exact name toexecute_toolcloudfaremcp_docsSearch the Cloudflare documentation.Read-onlyCloudflare Docs Search
Search the Cloudflare documentation. Use this tool to answer any question about Cloudflare products or features, including Workers, Pages, R2, Images, Stream, D1, Durable Objects, KV, Workflows, Hyperdrive, Queues, AI Search, Workers AI, Vectorize, AI Gateway, Browser Rendering, Zero Trust, Access, Tunnel, Gateway, Browser Isolation, WARP, DDOS, Magic Transit, Magic WAN, CDN, Cache, DNS, Zaraz, Argo, Rulesets, Terraform, Account and Billing. Results are returned as semantically similar chunks to the query.
Inputs
querystringrequired- Cloudflare documentation search query.
cloudfaremcp_searchSearch the Cloudflare OpenAPI spec.Read-onlyCloudflare Search
Search the Cloudflare OpenAPI spec. All $refs are pre-resolved inline. Response schemas describe the body as the API sends it, usually Cloudflare's envelope: `{ success, errors, messages, result }`, plus `result_info` on paginated lists. Products: cloudforce-one, access, workers, magic, dlp, email-security, realtime, devices, ai-gateway, data-security, email, intel, gateway, settings, stream, brand-protection, builds, ai-search, browser-rendering, security-center, dex, addressing, images, logpush, api_gateway, cws, load_balancers, firewall, rulesets, vectorize... (172 total) Types: interface OperationInfo { summary?: string; "x-api-token-group"?: string[]; // API token permissions the endpoint accepts (any one); OAuth scopes have the same names description?: string; tags?: string[]; parameters?: Array<{ name: string; in: string; required?: boolean; schema?: unknown; description?: string }>; requestBody?: { required?: boolean; content?: Record<string, { schema?: unknown }> }; // Each schema describes the body as the API sends it, usually the envelope { success, errors, messages, result, result_info? } responses?: Record<string, { description?: string; content?: Record<string, { schema?: unknown }> }>; } interface PathItem { get?: OperationInfo; post?: OperationInfo; put?: OperationInfo; patch?: OperationInfo; delete?: OperationInfo; } declare const spec: { paths: Record<string, PathItem>; }; Examples: // Find endpoints by product async () => { const results = []; for (const [path, methods] of Object.entries(spec.paths)) { for (const [method, op] of Object.entries(methods)) { if (op.tags?.some(t => t.toLowerCase() === 'workers')) { results.push({ method: method.toUpperCase(), path, summary: op.summary }); } } } return results; } // Get endpoint with requestBody schema (refs are resolved) async () => { const op = spec.paths['/accounts/{account_id}/d1/database']?.post; return { summary: op?.summary, requestBody: op?.requestBody }; } // Get endpoint parameters async () => { const op = spec.paths['/accounts/{account_id}/workers/scripts']?.get; return op?.parameters; }
Inputs
codestringrequired- JavaScript async arrow function that queries `spec.paths` to find matching Cloudflare API endpoints.
truncateboolean- Cap the result at ~6,000 tokens. Set to false only when the result goes straight to a file or pipe, not into the conversation: without the cap, a broad query can return megabytes.
cloudfaremcp_whoamiReturn the Cloudflare user or account that this connection is authenticated as.Read-onlyWhoami
Return the Cloudflare user or account that this connection is authenticated as. Takes no arguments. The id is stable across token refresh, reconnection and permission changes.
Inputs
This tool takes no inputs.
cloudfaremcp_executeExecute JavaScript code that can read, create, update, or delete resources through the Cloudflare API.WriteCloudflare Execute
Execute JavaScript code that can read, create, update, or delete resources through the Cloudflare API. First use the 'search' tool to find the right endpoints, then write code using the cloudflare.request() function. Available in your code: interface CloudflareRequestOptions { method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; path: string; query?: Record<string, string | number | boolean | undefined>; // Request headers the endpoint declares, such as { "cf-r2-jurisdiction": "eu" } for an R2 bucket // in a jurisdiction, or { "If-Match": etag }. Authorization is always the session's. headers?: Record<string, string>; // A string, bytes (Uint8Array, ArrayBuffer), Blob, FormData, URLSearchParams or stream is sent as // it is. Any other value is sent as JSON. Content-Type defaults to application/json for JSON and // for strings: set it in headers for other text, such as { "Content-Type": "text/plain" } for SQL, // and for bytes. FormData, Blob and URLSearchParams bring their own. body?: unknown; } // The response body as the API sends it. Most APIs wrap it in this envelope; a few send their JSON // bare (the spec's response schema shows which). Non-JSON responses are text, or a Uint8Array for // binary content (images, PDFs, archives). Bytes in the value your code returns appear as // { base64, byteLength }. A failed request throws. interface CloudflareEnvelope<T = unknown> { success: boolean; errors: Array<{ code: number; message: string }>; messages: Array<{ code: number; message: string }>; result: T; result_info?: { page: number; per_page: number; total_pages: number; count: number; total_count: number }; } declare const cloudflare: { request<T = CloudflareEnvelope>(options: CloudflareRequestOptions): Promise<T>; }; declare const accountId: string; // accountId is the account_id tool argument when passed; otherwise the session's account when it is authorized for exactly one. Reading it when neither applies throws an error. When the session has access to multiple accounts, pass account_id. Call GET /accounts to discover available accounts. Paginate as needed, or filter by exact name with GET /accounts?name=<exact account name>. Your code must be an async arrow function that returns the result. A failed request throws an Error naming the method, path, HTTP status and Cloudflare's errors. For HTTP 401/403 it also says which permission the endpoint needs and whether reconnecting will help. Requests slow down by themselves near a rate limit. For HTTP 429 the error says how long Cloudflare asks to wait; until then, requests under the same limit are not sent and throw too, so stop instead of catching and continuing. Example: Worker with bindings (a multipart/form-data upload): async () => { const code = `export default { async fetch(request, env) { return new Response(await env.MY_KV.get('key') || 'none') } };`; const metadata = { main_module: "worker.js", bindings: [{ type: "kv_namespace", name: "MY_KV", namespace_id: "your-kv-id" }] }; const form = new FormData(); form.append("metadata", new Blob([JSON.stringify(metadata)], { type: "application/json" })); form.append("worker.js", new Blob([code], { type: "application/javascript+module" }), "worker.js"); return cloudflare.request({ method: "PUT", path: `/accounts/${accountId}/workers/scripts/my-worker`, body: form }); }
Inputs
codestringrequired- JavaScript async arrow function that calls `cloudflare.request()` to interact with the Cloudflare API.
account_idstring- Your Cloudflare account ID. Auto-selected if you only have one account.
truncateboolean- Cap the result at ~6,000 tokens. Set to false only when the result goes straight to a file or pipe, not into the conversation: without the cap, a broad query can return megabytes.
No tools match.