Skip to content
Hidden Logic Lab

Cloudflare API MCP runs agent JavaScript against the entire API. Code Mode is on by default, and the payment policy does not stop a Worker deploy or a DNS change.

Published

The official Cloudflare API MCP server is a first-party Model Context Protocol server that lets an AI assistant search Cloudflare's OpenAPI document and call the Cloudflare API on behalf of a connected account. Publisher: Cloudflare. The public repository is cloudflare/mcp, licensed Apache-2.0. The implementation is TypeScript. It is a hosted Worker at https://mcp.cloudflare.com/mcp, not a package you install with npm.

This review pins the repository at research time. The repo has no Git tags and no GitHub Releases.

What we pinned

  • Git commit 66b361ed7c94153bb37a5d0c94874c860a86cb0c on default-branch main, subject chore(auth): upgrade workers-oauth-provider to 1.4.0 and drop the CIMD grant override (#443). The commit date is 26 November 2026, 06:57:56 Asia/Hong_Kong (25 November 2026, 22:57:56 +00:00). There is no annotated tag and no tag signature. After importing GitHub's web-flow public keys, git verify-commit reported a good signature from GitHub <noreply@github.com> with fingerprint 9684 79A1 AFF9 27E3 7D1A 566B B569 0EEE BB95 2194. That confirms GitHub's merge signature, not a maintainer-signed annotated tag.
  • package.json and the MCP handshake name this build cloudflare-api version 0.1.0. That is a source label, not a published npm release of this repository.
  • The OpenAPI document this tree ships is recorded in src/generated/forge-mcp/source.json as openapi@5d6f5851947a4fac58cd4cfaf2c52e8a25ca7c3a. src/spec-release.ts says Code Mode, the endpoint tools, and the forge tools all come from that release, and that a newer Forge release reaches the tree only after a reviewed pull request.
  • wrangler.jsonc names the production Worker cloudflare-api-mcp and the custom domain mcp.cloudflare.com. Official docs and the README both give the MCP URL as https://mcp.cloudflare.com/mcp.

At research time on the morning of 27 November 2026, Asia/Hong_Kong, cloudflare/mcp showed 1,196 stars and 190 forks. The repo is not archived. It was created 29 January 2026, 23:10:49 Asia/Hong_Kong (15:10:49 UTC). We pinned this commit, not a later HEAD.

We did not call https://mcp.cloudflare.com/mcp as a logged-in user, so we cannot say which commit the hosted service runs.

Scope

This is a static review of official evidence: the pinned git commit, the first-party TypeScript under src/ excluding the generated OpenAPI and tool tree, the tests and scripts we opened in that commit, the official docs at developers.cloudflare.com/agents/model-context-protocol/mcp-servers-for-cloudflare, and Cloudflare's 20 February 2026 Code Mode blog post.

We did not run the MCP server, Wrangler, npx, the Dynamic Worker sandbox, or any Cloudflare API call. We did not authenticate to Cloudflare, send traffic to mcp.cloudflare.com as a logged-in user, or use an API token or OAuth grant. We did not install the unrelated npm package named cloudflare-mcp. We read its public registry metadata only.

The tree also contains 2,148 files under src/generated/. We did not read that generated tree line by line. Findings about tools and policy come from the first-party TypeScript, tests, README, and docs we opened.

No malware was found in the first-party TypeScript we opened at 66b361ed. That is a statement about the scope we opened, not a clean bill of health and not a runtime confirmation.

Verdict

The official server is a first-party Cloudflare API client with a small MCP tool surface and a large authority surface. In the default Code Mode, the agent does not get one tool per API method. It gets search and execute, plus docs, whoami, and submit_feedback. execute is registered with destructiveHint: true and openWorldHint: true. Its description says the JavaScript can "read, create, update, or delete resources through the Cloudflare API," and the in-tool example is a PUT of a Worker script.

The interesting control is not a general write lock. src/policy-guards.ts refuses a narrow set of requests that spend money (domain registration or transfer, credit top-ups, subscriptions, invoice payments, payment methods) and some Workers AI runs (third-party models, and models the regex treats as image, video, or audio generation). Reads are never refused by that guard. The unit tests at this commit also allow writes the regex does not cover, including POST to a KV bulk-delete path and POST of a Workers AI text model. The execute tests send Worker uploads, R2 writes, and KV writes through the same outbound path.

The sandbox is real, and it is not a second permission system. A fresh Dynamic Worker isolate runs the agent's function. GlobalOutbound allows only the configured Cloudflare API hostname and injects the session token from isolate props, replacing any Authorization header the code set, so the token is documented as never entering the user-code isolate. That is a confinement of where the code can send HTTP, not of which Cloudflare writes the session may perform.

OAuth consent in this source defaults to the minimal template: user:read, account:read, and offline_access. Clients that support step-up can ask for more later, including the internal billing:read and billing:write scopes that no template lists up front. The same consent page also offers full-access, which includes the 400 derived catalog scopes — 171 of them are .write scopes, among them account-api-tokens.write. A bearer API token skips that consent screen entirely. Its Cloudflare permissions are the boundary, and the server treats it as a direct connection.

Official install examples are a URL and an optional bearer token. They do not show a read-only token, a least-privilege grant, or the fact that the payment policy is not a general mutation guard. This is not a clean bill of health.

What the server actually is

Cloudflare's docs call this "the only MCP server you need to work with Cloudflare." They say it provides access to the entire Cloudflare API — over 2,500 endpoints across DNS, Workers, R2, Zero Trust, and other products — and to Cloudflare developer documentation.

The README frames the design as Code Mode: the OpenAPI spec stays on the server, and the agent writes JavaScript against spec and cloudflare.request(). The same README table compares token cost for a raw spec, a native MCP tool per method, and Code Mode's three tools at about 1,100 tokens. Official docs say the generated code runs inside an isolated Dynamic Worker sandbox. The 20 February 2026 Cloudflare blog post introduces this server in those terms.

Code Mode is the default. src/server.ts registers search and execute unless codemode is false. src/mcp-handler.ts leaves Code Mode on unless the MCP URL has exactly ?codemode=false. That query parameter does not reduce what the credential can do. It replaces the two Code Mode tools with one generated tool per API method. The README says that is about 3,000 tools; the official docs table uses 2,594. We did not recount them. docs and whoami remain in both modes. In Code Mode, submit_feedback is also registered.

A separate catalog of product-specific Cloudflare MCP servers still exists (docs, containers, browser, and others). Those servers are out of scope. This review is the recommended API server in cloudflare/mcp.

Code Mode and the execute sandbox

search runs an async JavaScript function against the pre-resolved OpenAPI spec. The call is forwarded to the forge-tools service via env.FORGE_TOOLS.search(code). The search tool's own comment says that service runs the function next to the spec and that this Worker never holds the 27 MB document. The tool description says there is no network access in that search sandbox. We did not run it to confirm.

execute is the write path. runExecute in src/tools/execute.ts creates a fresh worker id per call, bakes the user's function into module source (the comment says dynamic-worker isolates disallow eval, so code cannot be passed into a warm isolate), and points globalOutbound at GlobalOutbound.

GlobalOutbound.fetch is the outbound proxy:

  • If the request hostname is not the hostname of CLOUDFLARE_API_BASE, it returns 403 Forbidden: requests to … are not allowed. In production config that base is https://api.cloudflare.com/client/v4.
  • It then runs policyRefusalHint. A refused chargeable subscription is not sent; the response can carry X-Cloudflare-MCP-Needs-Confirmation so the host can ask the user.
  • It rebuilds headers and sets Authorization: Bearer <apiToken> from isolate props, replacing any Authorization the sandboxed code sent. The comment is explicit: the token must not enter the user-code isolate, and appending a second Authorization header would produce a value the API could not read.

Inside the generated worker, globalThis.fetch is wrapped for rate-limit pacing, then calls the original fetch, which is the Worker Loader outbound path into GlobalOutbound. cloudflare.request() is a helper on top of that: it builds a URL as apiBase + path, encodes the body, and throws on failed HTTP or a Cloudflare envelope with success: false. GraphQL POST /graphql is treated as a read for replay-safety accounting, because the comment says that API has no mutations.

The sandbox result is untrusted and parsed with Zod. Scope-challenge and subscription-confirmation logic on the host side do not take the sandbox's word for a scope or a price without further checks: a reported scope must be a catalog scope the connection lacks, and a reported subscription is re-parsed from the request body GlobalOutbound already saw.

This is a careful design for token handling and outbound HTTP. It is not a promise that execute cannot change production DNS, Workers, KV, R2, or Access policy. The tool metadata says the opposite, and the in-description example uploads a Worker.

Results are capped at about 6,000 tokens in Code Mode unless the call passes truncate: false or the URL sets truncateToolResult=false. The README warns that a broad query can return megabytes if the cap is off.

Policy guards: what is blocked, and what is not

policyRefusalHint is shared. The file comment says both routes to the API call it: execute's GlobalOutbound and the generated tools. GET and HEAD always pass. A path that cannot be percent-decoded is refused, so the guard is not skipped by a malformed escape.

The chargeable-write regex covers, on this commit:

  • account registrar registrations
  • AI Gateway billing top-ups
  • payment methods and billing payment-method profile writes
  • account subscriptions, bulk subscriptions, and invoice payment
  • user subscriptions
  • zone subscriptions

The one chargeable write that can still be sent is POST /accounts/{account_id}/subscriptions after the user confirms that exact account, rate plan, and request-body digest. src/charge-confirmation.ts implements that as an MCP elicitation inside an input_required result. The question includes a price from the rate plan catalog. Clients that cannot be asked, in this source, keep the block. If earlier requests in the same execute program may already have changed resources (replaySafe is false), the host will not rerun the program to ask; the tool result tells the agent to send the subscription request in a call of its own.

Workers AI has a second, separate filter. Writes under /accounts/{id}/ai/ that name a model not prefixed with @cf/, or a model matching a media-generation regex (including black-forest-labs, stabilityai, runwayml, and deepgram/aura), are refused. A Workers AI text model is not. The tests allow POST …/ai/run with @cf/meta/llama-3.1-8b-instruct, and they allow @cf/openai/whisper and @cf/deepgram/nova-3. Those allowed runs can still consume Workers AI usage. The payment regex does not mention them.

The same test file also allows POST …/storage/kv/namespaces/ns1/bulk/delete. tests/execute-requests.test.ts exercises R2 object and bucket writes, KV value writes, Worker script PUTs, and a PATCH to workers/scripts/…/secrets-bulk. Those paths are not in the chargeable-write regex.

So the honest summary of this commit is: the server will not, according to this source, register a domain, add a payment method, pay an invoice, or create a subscription unless the user confirms that exact subscription. It will, according to this source and these tests, send other writes the credential authorizes, including deletes and deploys.

Credentials, OAuth defaults, and API tokens

There are two ways in.

OAuth is what the README and the official docs recommend. Connecting to https://mcp.cloudflare.com/mcp redirects to Cloudflare to authorize and select permissions. In this source, if the client does not ask for scopes beyond the required identity set, src/auth/oauth-handler.ts fills in the minimal template: user:read, account:read, and offline_access. The consent page still lets the user pick read-only or full-access, or edit an advanced scope list. full-access is every derived catalog scope except the two internal billing scopes. Those billing scopes can still be added later by step-up when a call needs them. Policy guards still apply after a scope is granted; a billing scope is not a silent bypass of the chargeable-write list.

Step-up is a first-class path. When Cloudflare refuses a call for a missing scope, the server can return an insufficient_scope challenge. The README says some endpoints, such as GET /zones, answer with an empty list instead of refusing, and that an empty list from a read the connection holds no accepted scope for is also refused, so it is not mistaken for an empty account.

API token mode is for CI/CD or operators who pass Authorization: Bearer themselves. User tokens and account tokens are supported. Prefixes cfat_, cfut_, and cfoat_ are treated as ownership hints; unprefixed legacy tokens remain supported. The README says tokens with Client IP Address Filtering are not currently supported. Identity for a direct token is probed against the Cloudflare API and cached in OAUTH_KV under a SHA-256 of the token, with a 2,592,000-second TTL in this source (thirty days). The cache stores identity, not the raw token. A token the provider itself issued, then dropped, is not sent to Cloudflare for a second opinion.

src/api-permissions.ts treats a non-OAuth credential as a direct connection. Direct connections do not step up. The token's Cloudflare permission groups are the control, plus the same policy guards. A broad edit token in a client that auto-approves execute is, in this design, a broad edit session.

whoami returns { id, email } for a user credential, or { id, name } for an account token. The user email is described as display metadata, not the profile id. It still leaves the account email in the model context when the credential carries one.

Official JSON examples in the README and docs show only the MCP URL. They do not show ?codemode=false, a read-only token, or a warning to stay on the Minimal card. The safer defaults live in the consent code, not in the copy-paste config.

Skills, docs, metrics, and other network paths

The server also serves Cloudflare skills (the README names Wrangler, Durable Objects, Agents SDK, and Workers best practices) through the MCP Skills extension. src/skills/sync.ts downloads https://codeload.github.com/cloudflare/skills/tar.gz/refs/heads/main and stores the files in R2. The cron in wrangler.jsonc is 0 */6 * * *. The default branch is not pinned to this MCP commit. A failed sync keeps the previous manifest. Isolates cache the manifest for an hour. We did not review the current cloudflare/skills tree, and we cannot say which skills commit the hosted server was serving at research time.

docs searches Cloudflare developer documentation through Workers AI AutoRAG (ai.autorag('docs-mcp-rag').search). The search query leaves the client and is processed by that Cloudflare service. We did not run it.

Code Mode tool calls are logged to a Cloudflare Analytics Engine dataset via src/metrics.ts. The documented fields are the server name and version, a user id for user tokens (account tokens leave that blob unset), the tool name, and an error code. The file says no blob holds a response value. That is vendor telemetry about use of this server, not a third-party pixel. The OAuth approval HTML in src/auth/workers-oauth-utils.ts also loads Google Fonts. That is the consent page in the browser, not the execute sandbox.

submit_feedback can send a feedback payload to Cloudflare. Its prompt tells the agent to leave out secrets, tokens, personal data, account or zone IDs, and full conversations. That is a prompt, not a filter we verified at runtime.

Malware check and the npm name

In the first-party TypeScript we opened, outbound hosts were Cloudflare properties, GitHub (codeload.github.com for skills, and a documentation link to this repo), the Skills specification on GitHub, JSON Schema URLs, a ChatGPT OAuth client-metadata URL in src/clients.ts, and Google Fonts on the consent page. We found no hidden webhook, no typo-squat import in that first-party tree, and no eval or new Function in the first-party src/ we grepped. The execute sandbox is assembled as a string module precisely because, the comment says, the loader isolate does not allow eval.

child_process appeared only in maintainer scripts, not in the Worker server path we reviewed.

The npm registry has a package named cloudflare-mcp. At research time it was version 0.0.0, described as WIP, with a readme titled electron-mcp-manager, maintained by lottamus. It is not this repository. @cloudflare/mcp and @cloudflare/mcp-server returned 404 from the registry. The official install path in the docs and README is the hosted URL, or the Cloudflare skills plugin that points at that URL. Do not treat an unscoped npm install of cloudflare-mcp as this product. We did not download or run that registry package.

Who this is for, and who should not use the default

This server is for operators who already trust an assistant with some Cloudflare work and who will set a tight OAuth grant or API token, leave client tool approval on, and treat execute as production API access.

It is a poor default for an unattended agent, a client that auto-approves tool calls, a global edit token, or a Full access grant on an account that holds production DNS, Workers, customer data in KV or R2, or Zero Trust policy. The payment guard will not save that account from a bad deploy or a DNS change.

If you only wanted documentation search, the docs server at https://docs.mcp.cloudflare.com/mcp is the narrower official option. We did not review it in this article.

How a careful operator would pin and restrict it

We did not run these steps. They follow from the official docs and from the pinned source.

Connect to https://mcp.cloudflare.com/mcp with OAuth, and leave the consent page on Minimal unless a specific task needs more. Prefer step-up over starting at Full access. Do not grant account-api-tokens.write to an assistant that does not need to mint tokens.

If you use an API token, create a dedicated one with the narrowest permission groups and resources the job needs. Do not paste a broad dashboard token into the client. Do not rely on Client IP Address Filtering; this source says that restriction is not supported here. Store the token in the client's secret store, not in a chat.

Keep the MCP client's manual approval for execute enabled. Read the code the model wants to run before you approve it. A single function can issue many API calls.

Do not assume the hosted endpoint is this commit. This repo has no release tags, and we did not inspect the live Worker. Do not assume ?codemode=false is a security control; it only changes how tools are listed and called. Do not assume the six-hourly skills sync is frozen at this review.

Do not install the unscoped npm name cloudflare-mcp and expect this server.

Close

This was a static review of cloudflare/mcp at 66b361ed7c94153bb37a5d0c94874c860a86cb0c, with the OpenAPI pin openapi@5d6f5851947a4fac58cd4cfaf2c52e8a25ca7c3a. No malware was found in the first-party TypeScript we opened. Code Mode is on by default. execute is documented as destructive, runs agent JavaScript in a Dynamic Worker isolate, and sends session-authenticated requests to the Cloudflare API except for a narrow payment and media-model policy. Official install examples are a URL and an optional bearer token. We did not run the server or use a Cloudflare credential. This is not a clean bill of health.

More skill reviews

← All skill reviews