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
JSONRPCMessageSchemafor 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
$refresolution supports JSON Pointers (#/definitions/...,#/$defs/...)- Support for JSON Schema 2020-12
prefixItemsand OpenAPI 3.0nullable: true - Per-tool error isolation prevents one malformed schema from crashing the full pipeline
- Fallback to
{ type: "object" }wheninputSchemais 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-deniedstate for Anthropic provider compatibility - Abort/cancel support — Streaming responses correctly cancel the reader loop and signal completion to clients
- Message deduplication —
persistMessages()reconciles duplicate assistant messages by content and order - Error tagging —
requestIdinOnChatMessageOptionsenables properly-tagged error responses - Thinking preservation — Anthropic
redacted_thinkingblocks are no longer stripped by the sanitizer - Endpoint reliability —
/get-messagesnow works correctly when users overrideonRequest()without callingsuper.onRequest() - Undeprecated client APIs —
createToolsFromClientSchemas,clientTools, and related APIs restored for runtime-defined tools - Schema initialization — Fixed errors when calling
getAITools()inonChatMessage
Getting Started
Update to the latest version with:
npm i agents@latest @cloudflare/ai-chat@latest