← Back
Cloudflare
Agents SDK v0.6.0 adds RPC transport for MCP, optional OAuth, and schema hardening
Cloudflare Workers · releasefeatureapisdkperformance · developers.cloudflare.com ↗

RPC Transport for MCP Connections

The Agents SDK now supports connecting an Agent to an McpAgent within the same Worker using Durable Object bindings instead of HTTP URLs. This eliminates network overhead and keeps all communication within the Cloudflare runtime.

Key features of the RPC transport:

  • Zero-network connections — Pass the Durable Object namespace directly to addMcpServer() without HTTP serialization
  • Hibernation support — RPC connections automatically survive Durable Object hibernation with persistent binding names and context props
  • Deduplication — Calling addMcpServer() with the same server name returns the existing connection, with stable IDs across hibernation
  • Smaller footprint — Transport internals reduced from 609 lines to 245 lines, using MCP SDK's JSONRPCMessageSchema for validation

Simplified OAuth Configuration

OAuth is now opt-in rather than automatic. Servers that don't require authentication can be connected with a single line of code:

await this.addMcpServer("my-server", "https://mcp.example.com");

When a server requires authentication, the SDK provides a clear error message guiding developers to add OAuth config. The restore-from-storage flow gracefully skips auth provider creation for non-OAuth servers.

Production-Ready Schema Conversion

The JSON Schema to TypeScript converter has been hardened to handle edge cases that previously caused crashes:

  • Circular reference and depth guards prevent stack overflows
  • $ref resolution supports JSON Pointers (#/definitions/..., #/$defs/...)
  • Support for JSON Schema 2020-12 prefixItems and OpenAPI 3.0 nullable: true
  • Per-tool error isolation prevents one malformed schema from crashing the full pipeline
  • Fallback to { type: "object" } when inputSchema is missing

@cloudflare/ai-chat Reliability Improvements

A batch of bug fixes improve streaming and message handling:

  • Tool denial flow — Denied tool approvals now properly transition to output-denied state for Anthropic provider compatibility
  • Abort/cancel support — Streaming responses correctly cancel the reader loop and signal completion to clients
  • Message deduplicationpersistMessages() reconciles duplicate assistant messages by content and order
  • Error taggingrequestId in OnChatMessageOptions enables properly-tagged error responses
  • Thinking preservation — Anthropic redacted_thinking blocks are no longer stripped by the sanitizer
  • Endpoint reliability/get-messages now works correctly when users override onRequest() without calling super.onRequest()
  • Undeprecated client APIscreateToolsFromClientSchemas, clientTools, and related APIs restored for runtime-defined tools
  • Schema initialization — Fixed errors when calling getAITools() in onChatMessage

Getting Started

Update to the latest version with:

npm i agents@latest @cloudflare/ai-chat@latest