Cloudflare OS supports the Model Context Protocol (MCP) natively, letting agents and Gadgets connect to any MCP-compatible server as a typed capability. Each of the server’s tools becomes a named method on the session, generated from the server’s ownDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/cloudflare/cloudflare-os/llms.txt
Use this file to discover all available pages before exploring further.
inputSchema, so agents get full type information and can call tools as if they were first-class APIs.
Two MCP Gatekeepers
Cloudflare OS ships two complementary MCP gatekeepers:gatekeeper-mcp | gatekeeper-mcp-portal | |
|---|---|---|
| Endpoint source | User pastes a URL | Admin sets MCP_PORTAL_URL in deployment config |
| Who can use it | Any user, any endpoint | Everyone in the organization, via one portal |
| Trust tier | byo (user-supplied) | byo by default; vetted if MCP_PORTAL_TRUST_ANNOTATIONS=true |
| Auto-approve writes | Never | Only when vetted + annotation permits |
| Grant scope | Whole server, or named tools | One upstream server behind the portal, or named tools |
| No connect form | User supplies the endpoint | No endpoint form — admin pre-configures it |
@gadgets/mcp-shared library, which owns the MCP client, OAuth lifecycle, tool classification logic, scope grammar, and approval-queue wiring.
Trust Model
The trust tier governs how far a server’s own claims about its tools are believed:- byo (user-supplied)
- vetted (portal only)
The default for all
gatekeeper-mcp endpoints and for gatekeeper-mcp-portal without MCP_PORTAL_TRUST_ANNOTATIONS.- A tool annotated
readOnlyHint: trueruns as an observation and returns immediately - All other tools are queued for human approval before the call reaches the server
- No claim the server makes can auto-apply a write
readOnlyHint on byo is a deliberate tradeoff: refusing it would mean an approval prompt for every search and list, making the connector impractical. The limit is that writes are never auto-applied on the server’s word alone.=== true or === false, so an unannotated tool is treated as an action, always queued for approval, and can never auto-apply on either tier.
Session API
Each tool on the connected MCP server becomes a typed method on the session, generated from the server’sinputSchema. For example, for a Linear MCP server:
https://mcp.linear.app/mcp suggests MCP_LINEAR. The agent receives the full generated .d.ts as static documentation, where each method carries the tool’s own description as JSDoc and states whether calling it needs approval.
Grant Scope Grammar
Both gatekeepers share the same resource-URL scope grammar, implemented in@gadgets/mcp-shared/scope:
| Grant | Resource URL format | What’s accessible |
|---|---|---|
| Whole server | <endpoint> | Every tool the server offers, including ones added later |
| Named tools | <endpoint>#tool=a&tool=b | Only the listed tools; all others are refused |
| Portal server | <endpoint>#server=github | Every tool of one upstream server behind the portal |
| Portal server + tools | <endpoint>#server=github&tool=a&tool=b | Only the listed tools of one upstream server |
#server= fragments are refused by gatekeeper-mcp — scoping to a single server behind a portal is the portal connector’s grammar only.
Setting Up gatekeeper-mcp
gatekeeper-mcp requires no admin pre-configuration. Users supply endpoints themselves.
Configure optional variables
In the gatekeeper Worker’s environment or No per-server credentials are needed. Users supply endpoints via the connect form and the gatekeeper handles OAuth discovery automatically.
.dev.vars:.dev.vars
User connects a server
- The user opens a Gadget’s Connections tab and clicks + New Connection → MCP.
- They paste the MCP endpoint URL (e.g.,
https://mcp.linear.app/mcp). - The gatekeeper validates the endpoint (HTTPS required; private/loopback IPs blocked unless
MCP_ALLOW_INSECURE). - If the server requires OAuth, the standard discovery chain runs: protected resource metadata → authorization server metadata → dynamic client registration → PKCE authorization code flow.
- After authorization, the user chooses the grant breadth: All tools or Choose tools.
- The Gadget now has a typed session for the connected server.
Setting Up gatekeeper-mcp-portal
gatekeeper-mcp-portal is designed for organizations that run a centralized MCP server portal — such as a Cloudflare MCP server portal — and want every user to connect through it without typing endpoint URLs.
Configure the portal endpoint
Set the required variables in the portal gatekeeper’s deployment configuration or local If
.dev.vars:.dev.vars
MCP_PORTAL_URL is unset or invalid, the connector hides itself from the Connections UI rather than offering a connector that fails on first use.User connects to the portal
Once configured, users do not need to type any endpoint URL. Pressing Connect on the portal connector goes straight to the portal’s sign-in flow. After authorizing, the user sees a list of upstream servers the portal exposes and chooses which one (and which tools) to grant to the Gadget.
OAuth Support
Both MCP gatekeepers run the full MCP OAuth 2.0 discovery chain automatically when a server responds with401. The chain follows:
/authorize, /token, /register) for servers that do not publish discovery metadata. Tokens are stored in the account’s Durable Object and refreshed proactively before expiry. A mid-session 401 marks the account as needing reconnection rather than triggering a refresh — the token was believed valid, so a rejection means revocation, not expiry.
All SDK OAuth operations use
sdkFetch internally, which re-runs endpoint and SSRF checks on every request and redirect hop — including those the OAuth library itself follows.Sharing Limitations
MCP Gadgets are owner-only. A Gadget bound to any MCP endpoint cannot be shared with collaborators —addObserver refuses unconditionally. Being able to authenticate to a server is not evidence of being allowed to see what the owner read from it, and the Gadget runs on the owner’s credentials throughout.
To collaborate on MCP-based work, publish the Gadget as a Blueprint and let each person connect their own MCP server.
Current Limitations
- No simulation. MCP has no way to predict a tool’s effect, so queued calls are not reflected in later reads. The agent’s turn suspends until you decide on the pending action.
- No revert. MCP has no inverse for a tool call, so rejected actions cannot be undone.
- No scoping below tool names. The narrowest grant available is a list of allowed tool names — “this repo only” cannot be expressed.
- Only
tools/*. Prompts, resources, sampling, and elicitation are not implemented.