Cloudflare’s Agent Stack Gains Remote MCP Clients, Auth Integrations, and Free Durable Objects

Cloudflare’s bet on agentic AI development is deepening with a wave of platform updates aimed at production use. The company is expanding its Agents SDK beyond server-side MCP support, adding out-of-the-box remote client capabilities, integrated third-party authentication, and a stateful runtime that no longer requires a paid plan for experimentation.

The headline feature is the new MCPClientManager class in the Agents SDK, which lets AI agents connect to remote MCP servers as clients — not just host them. The SDK now handles the plumbing that developers previously had to assemble by hand: remote transport over SSE and HTTP (with Streamable HTTP support on the roadmap), automatic connection tracking and reconnection, discovery of servers’ tools, resources, and prompts at runtime, and live updates when those capabilities change. When multiple servers are in play, the manager namespaces all tools and resources so identical function names from different providers don’t collide; an “analyze” tool from an image server and one from a code server stay independently callable.

Authentication is built in rather than bolted on. The SDK supports the OAuth 2.1 flow end to end, generating code challenges, redirecting users to a service’s login page, exchanging authorization codes for access tokens, and attaching those tokens to authenticated requests. Even the authorization endpoint, token exchange, and refresh logic are handled by the client manager’s internals; for developer convenience, the broader MCP tooling on Cloudflare works with bring-your-own OAuth providers, including Stytch, Auth0, and WorkOS.

That remote client pattern opens up several concrete use cases out of the box:

  • Prompting an end user to grant a third-party service access, then using that service’s tools on their behalf.
  • Invoking MCP servers from Workflows, scheduled jobs, or anywhere else in an agent’s execution path.
  • Connecting to multiple MCP servers simultaneously so an agent can mix and match tools from different providers without hardcoding the integration.

Internally, the client manager tracks every registered server through an mcpConnections dictionary that maps server names to their own MCPClientConnection instances. Each connection runs its own auth context, so one agent can stay authenticated to several services in the same session. Registering a connection is a two-step process under the hood: a new connection instance is created with server-specific creds, then that connection is initialized and subscribes to capability change notifications.

async onStart(): Promise<void> {
  // initialize MCPClientManager which manages multiple MCP clients with optional auth
  this.mcp = new MCPClientManager("my-agent", "1.0.0", {
    baseCallbackUri: `${serverHost}/agents/${agentNamespace}/${this.name}/callback`,
    storage: this.ctx.storage,
  });
}

async addMcpServer(url: string): Promise<string> {
  // Add one MCP client to our MCPClientManager
  const { id, authUrl } = await this.mcp.connect(url);
  // Return authUrl to redirect the user to if the user is unauthorized
  return authUrl
}

async onRequest(req: Request): Promise<void> {
  // handle the auth callback after being finishing the MCP server auth flow
  if (this.mcp.isCallbackRequest(req)) {
    await this.mcp.handleCallbackRequest(req);
    return new Response("Authorized")
  }
  
  // ...
}

Stateful server-side agents also get a new operational mode. McpAgent instances now support hibernation: remote MCP servers can sleep during idle windows and wake on demand, which preserves long-running session state while sidestepping compute charges for inactive time. That feature is paired with two related pricing and infrastructure moves. Durable Objects — the stateful backbone underneath many agent workloads on the platform — has been moved into Cloudflare’s free tier, removing the paywall for SDK experiments. Workflows has reached general availability, giving agents a production-grade primitive for long-running, multi-step actions. Cloudflare has also rolled out AutoRAG for click-through RAG pipeline setup and a new aggregator site at agents.cloudflare.com for the growing collection of agent-building documentation.

The cumulative effect of these releases is a more complete agent stack where the previously awkward seams — connections, auth, state, and orchestration — are filled in by the platform rather than the developer. With both client-side and server-side MCP support now in the SDK, Cloudflare is positioning itself as the neutral middle layer for agents talking to agents, plus human-approved access to external tools and services. For developers, it means fewer custom auth servers and connection managers to build, and a lower barrier to trying the entire workflow on the free plan before committing to production. A deployable remote MCP client demo is available from the repository linked below.

Adding authentication to remote MCP servers

When your application is accessed through MCP, AI agents act on behalf of users rather than relying on a dashboard or API as the entrypoint. That means your existing authentication and authorization system needs to extend to these agentic interactions, including login flows, permissions scopes, consent forms, and access enforcement for your MCP server.

To make this easier, Cloudflare has added integrations with Stytch, Auth0, and WorkOS. These integrations let developers building MCP servers:

  • Authenticate users through email, social logins, SSO, and MFA.
  • Define scopes and permissions that map directly to MCP tools.
  • Present users with a consent page corresponding to requested permissions.
  • Enforce permissions so agents can only invoke permitted tools.
BLOG-2721 Image 3

You can deploy demo MCP servers to your Cloudflare account using the “Deploy to Cloudflare” button. These demos include pre-configured authentication endpoints, consent flows, and permission models you can customize. Once deployed, test the end-to-end user flow with the Workers AI playground, a browser-based remote MCP client.

Stytch

The Stytch example implements a remote MCP server where users sign in with email, Google login, or enterprise SSO to authorize an AI agent to view and manage company OKRs. Stytch restricts the scopes granted to the agent based on the user's role and permissions within their organization. Each user sees a consent page outlining the permissions the agent requests and which ones they are authorized to grant.

Deploy to Cloudflare

For consumer use cases, deploy a remote MCP server for a To Do app that uses Stytch for authentication and MCP client authorization. Users sign in with email to access their own To Do lists and can grant access to any AI assistant to help manage tasks.

Deploy to Cloudflare

With Stytch, you can turn your application into an OAuth 2.0 identity provider and make your remote MCP server a Relying Party, inheriting identity and permissions from your app. More details are available in Stytch's blog post.

“One of the challenges of realizing the promise of AI agents is enabling those agents to securely and reliably access data from other platforms. Stytch Connected Apps is purpose-built for these agentic use cases, making it simple to turn your app into an OAuth 2.0 identity provider to enable secure access to remote MCP servers. By combining Cloudflare Workers with Stytch Connected Apps, we're removing the barriers for developers, enabling them to rapidly transition from AI proofs-of-concept to secure, deployed implementations.” — Julianna Lamb, Co-Founder & CTO, Stytch.

Auth0

The Auth0 example authenticates users through email, social logins, or enterprise SSO to interact with todos and personal data via AI agents. The MCP server securely connects to API endpoints on the user's behalf, showing exactly which resources the agent will access once the user consents. Access tokens refresh automatically during long-running interactions.

Deploy the protected API endpoint first:

Deploy to Cloudflare

Then deploy the MCP server that handles Auth0 authentication and connects agents to the API endpoint:

Deploy to Cloudflare
“Cloudflare continues to empower developers building AI products with tools like AI Gateway, Vectorize, and Workers AI. The recent addition of Remote MCP servers further demonstrates that Cloudflare Workers and Durable Objects are a leading platform for deploying serverless AI. We're very proud that Auth0 can help solve the authentication and authorization needs for these cutting-edge workloads.” — Sandrino Di Mattia, Auth0 Sr. Director, Product Architecture.

WorkOS

WorkOS's AuthKit handles authentication and permission management in this example. The MCP server dynamically exposes tools based on the user's role and access rights. All authenticated users get the add tool, but only users assigned the image_generation permission in WorkOS can grant agents access to the image generation tool. This shows how MCP servers can conditionally expose capabilities based on the authenticated user's role.

Deploy to Cloudflare
“MCP is becoming the standard for AI agent integration, but authentication and authorization are still major gaps for enterprise adoption. WorkOS Connect enables any application to become an OAuth 2.0 authorization server, allowing agents and MCP clients to securely obtain tokens for fine-grained permission authorization and resource access. With Cloudflare Workers, developers can rapidly deploy remote MCP servers with built-in OAuth and enterprise-grade access control. Together, WorkOS and Cloudflare make it easy to ship secure, enterprise-ready agent infrastructure.” — Michael Grinich, CEO of WorkOS.

WebSocket hibernation for idle MCP servers

The McpAgent class now supports the WebSockets Hibernation API, letting your MCP server sleep during idle periods and wake instantly when needed — which means you only pay for compute while your agent is actually working.

McpAgent, built on Durable Objects, was designed to maintain stateful connections for every client session so developers can build servers that remember context, user preferences, and conversation history. But long-lived client connections can stay active even when unused, incurring costs for idle sessions.

Hibernation by default

With the latest SDK update, all McpAgent instances automatically include hibernation support — no code changes required. Your stateful MCP servers sleep during inactive periods and wake up with state preserved.

How hibernation works

When a request arrives on the Server-Sent Events endpoint (/sse), the Worker initializes a WebSocket connection to the appropriate Durable Object for the session and returns an SSE stream to the client. All responses flow over this stream. Using the WebSocket Hibernation API within Durable Objects, the Durable Object can be evicted from memory after periods of inactivity while keeping the WebSocket connection open. If the WebSocket later receives a message, the runtime recreates the Durable Object and delivers the message to the appropriate handler.

Durable Objects on the free tier

Durable Objects are now available on the free tier, so you can build AI agents with the Agents SDK at zero cost. Each Durable Object provides compute alongside durable storage, enabling stateful, serverless applications when combined with Workers. They act as stateful coordinators for client real-time interactions, make requests to external services like LLMs, and create agentic memory through state persistence in zero-latency SQLite storage — all tasks required in an AI agent. Durable Objects scale out to millions of agents, each created near the user it serves, all managed by Cloudflare.

SQLite storage in Durable Objects, introduced in public beta in September 2024, is now generally available with a 10 GB SQLite database per Durable Object. Cloudflare recommends SQLite storage for all new Durable Object classes. Durable Objects on the free tier can only access SQLite storage.

On the free plan, every Worker request can call a Durable Object. For usage-based pricing, Durable Objects incur compute and storage usage with these free tier limits:

 

Workers Free

Workers Paid

Compute: Requests

100,000 / day

1 million / month included

+ $0.15 / million

Compute: Duration

13,000 GB-s / day

400,000 GB-s / month  included 

+ $12.50 / million GB-s

Storage: Rows read

5 million / day

25 billion / month included

+ $0.001 / million 

Storage: Rows written

100,000 / day

50 million / month included

+ $1.00 / million

Storage: SQL stored data

5 GB (total)

5 GB-month included

+ $0.20 / GB-month

To learn more about building agents on Cloudflare — whether you're new or experienced — visit the new agents.cloudflare.com site.