agents@0.6.0
cloudflare/agentsagents@0.6.0Feb 25, 2026by github-actions[bot]
AI Summary
A significant minor release introducing RPC transport for MCP connections via Durable Object bindings, with hibernation support and connection deduplication. Also includes JSON Schema to TypeScript converter hardening and OAuth flow improvements.
Key Highlights
- New RPC transport for MCP: connect Agents to McpAgent via Durable Object bindings without HTTP overhead
- Hibernation support: RPC connections survive DO hibernation automatically
- Connection deduplication: addMcpServer returns existing connection when called multiple times
- Made callbackHost optional for non-OAuth MCP servers (simplifies setup)
- Hardened JSON Schema to TypeScript converter with circular reference guards and $ref resolution
New Features
- addMcpServer now accepts DurableObjectNamespace as second parameter for RPC transport
- RPC connections persist across hibernation with binding name and props restored on wake-up
- New AddRpcMcpServerOptions type for type-safe RPC configuration
- Console warning noting experimental status of RPC transport API
Full Release Notes
### Minor Changes
- [#565](https://github.com/cloudflare/agents/pull/565) [`0e9a607`](https://github.com/cloudflare/agents/commit/0e9a607888a4ef31adc226d0fa939b9125cbfea0) Thanks [@mattzcarey](https://github.com/mattzcarey)! - Add RPC transport for MCP: connect an Agent to an McpAgent via Durable Object bindings
**New feature: `addMcpServer` with DO binding**
Agents can now connect to McpAgent instances in the same Worker using RPC transport — no HTTP, no network overhead. Pass the Durable Object namespace directly:
```typescript
// In your Agent
await this.addMcpServer("counter", env.MY_MCP);
// With props
await this.addMcpServer("counter", env.MY_MCP, {
props: { userId: "user-123", role: "admin" },
});
```
The `addMcpServer` method now accepts `string | DurableObjectNamespace` as the second parameter with proper TypeScript overloads, so HTTP and RPC paths are type-safe and cannot be mixed.
**Hibernation support**
RPC connections survive Durable Object hibernation automatically. The binding name and props are persisted to storage and restored on wake-up, matching the behavior of HTTP MCP connections. No need to manually re-establish connections in `onStart()`.
**Deduplication**
Calling `addMcpServer` with the same server name multiple times (e.g., across hibernation cycles) now returns the existing connection instead of creating duplicates. This applies to both RPC and HTTP connections. Connection IDs are stable across hibernation restore.
**Other changes**
- Rewrote `RPCClientTransport` to accept a `DurableObjectNamespace` and create the stub internally via `getServerByName` from partyserver, instead of requiring a pre-constructed stub
- Rewrote `RPCServerTransport` to drop session management (unnecessary for DO-scoped RPC) and use `JSONRPCMessageSchema` from the MCP SDK for validation instead of 170 lines of hand-written validation
- Removed `_resolveRpcBinding`, `_buildRpcTransportOptions`, `_buildHttpTransportOptions`, and `_connectToMcpServerInternal` from the Agent base class — RPC transport logic no longer leaks into `index.ts`
- Added `AddRpcMcpServerOptions` type (discriminated from `AddMcpServerOptions`) so `props` is only available when passing a binding
- Added `RPC_DO_PREFIX` constant used consistently across all RPC naming
- Fixed `MCPClientManager.callTool` passing `serverId` through to `conn.client.callTool` (it should be stripped before the call)
- Added `getRpcServersFromStorage()` and `saveRpcServerToStorage()` to `MCPClientManager` for hibernation persistence
- `restoreConnectionsFromStorage` now skips RPC servers (restored separately by the Agent class which has access to `env`)
- Reduced `rpc.ts` from 609 lines to 245 lines
- Reduced `types.ts` from 108 lines to 26 lines
- Updated `mcp-rpc-transport` example to use Workers AI (no API keys needed), Kumo/agents-ui components, and Tailwind CSS
- Updated MCP transports documentation
### Patch Changes
- [#973](https://github.com/cloudflare/agents/pull/973) [`969fbff`](https://github.com/cloudflare/agents/commit/969fbff702d5702c1f0ea6faaecb3dfd0431a01b) Thanks [@threepointone](https://github.com/threepointone)! - Update dependencies
- [#960](https://github.com/cloudflare/agents/pull/960) [`179b8cb`](https://github.com/cloudflare/agents/commit/179b8cbc60bc9e6ac0d2ee26c430d842950f5f08) Thanks [@mattzcarey](https://github.com/mattzcarey)! - Harden JSON Schema to TypeScript converter for production use
- Add depth and circular reference guards to prevent stack overflows on recursive or deeply nested schemas
- Add `$ref` resolution for internal JSON Pointers (`#/definitions/...`, `#/$defs/...`, `#`)
- Add tuple support (`prefixItems` for JSON Schema 2020-12, array `items` for draft-07)
- Add OpenAPI 3.0 `nullable: true` support across all schema branches
- Fix string escaping in enum/const values, property names (control chars, U+2028/U+2029), and JSDoc comments (`*/`)
- Add per-tool error isolation in `generateTypes()` so one malformed schema cannot crash the pipeline
- Guard missing `inputSchema` in `getAITools()` with a fallback to `{ type: "object" }`
- Add per-tool error isolation in `getAITools()` so one bad MCP tool does not break the entire tool set
- [#963](https://github.com/cloudflare/agents/pull/963) [`b848008`](https://github.com/cloudflare/agents/commit/b848008549f57147e972a672f88789a05fa2c14d) Thanks [@threepointone](https://github.com/threepointone)! - Make `callbackHost` optional in `addMcpServer` for non-OAuth servers
Previously, `addMcpServer()` always required a `callbackHost` (either explicitly or derived from the request context) and eagerly created an OAuth auth provider, even when connecting to MCP servers that do not use OAuth. This made simple non-OAuth connections unnecessarily difficult, especially from WebSocket callable methods where the request context origin is unreliable.
Now, `callbackHost` and the OAuth auth provider are only required when the MCP server actually needs OAuth (returns a 401/AUTHENTICATING state). For non-OAuth servers, `addMcpServer("name", url)` works with no additional options. If an OAuth server is encountered without a `callbackHost`, a clear error is thrown: "This MCP server requires OAuth authentication. Provide callbackHost in addMcpServer options to enable the OAuth flow."
The restore-from-storage flow also handles missing callback URLs gracefully, skipping auth provider creation for non-OAuth servers.
- [`97c6702`](https://github.com/cloudflare/agents/commit/97c67023a105dfe9413ebb0ea7c9888bb9335456) Thanks [@threepointone](https://github.com/threepointone)! - Add one-time console warning when using RPC transport (DO binding) with `addMcpServer`, noting the API is experimental and linking to the feedback issue.