{"id":251,"date":"2026-02-25T00:00:00","date_gmt":"2026-02-25T00:00:00","guid":{"rendered":"https:\/\/wordpress.securinsight.ca\/index.php\/2026\/02\/25\/agents-workers-agents-sdk-v0-6-0-rpc-transport-for-mcp-optional-oauth-hardened-schema-conversion-and-cloudflare-ai-chat-fixes\/"},"modified":"2026-02-25T00:00:00","modified_gmt":"2026-02-25T00:00:00","slug":"agents-workers-agents-sdk-v0-6-0-rpc-transport-for-mcp-optional-oauth-hardened-schema-conversion-and-cloudflare-ai-chat-fixes","status":"publish","type":"post","link":"https:\/\/wordpress.securinsight.ca\/index.php\/2026\/02\/25\/agents-workers-agents-sdk-v0-6-0-rpc-transport-for-mcp-optional-oauth-hardened-schema-conversion-and-cloudflare-ai-chat-fixes\/","title":{"rendered":"Agents, Workers &#8211; Agents SDK v0.6.0: RPC transport for MCP, optional OAuth, hardened schema conversion, and @cloudflare\/ai-chat fixes"},"content":{"rendered":"<p>The latest release of the <a href=\"https:\/\/github.com\/cloudflare\/agents\" target=\"_blank\">Agents SDK<\/a> lets you define an Agent and an McpAgent in the same Worker and connect them over RPC \u2014 no HTTP, no network overhead. It also makes OAuth opt-in for simple MCP connections, hardens the schema converter for production workloads, and ships a batch of <code>@cloudflare\/ai-chat<\/code> reliability fixes.<\/p>\n<h4>RPC transport for MCP<\/h4>\n<p>You can now connect an Agent to an McpAgent in the same Worker using a Durable Object binding instead of an HTTP URL. The connection stays entirely within the Cloudflare runtime \u2014 no network round-trips, no serialization overhead.<\/p>\n<p>Pass the Durable Object namespace directly to <code>addMcpServer<\/code>:<\/p>\n<ul>\n<li>\n<p>JavaScript<\/p>\n<div>\n<div>\n<figure>\n<pre data-language=\"js\"><code class=\"language-js\"><div><div><span>import <\/span><span>{<\/span><span><span> <\/span><span>Agent<\/span><span> <\/span><\/span><span>}<\/span><span> from <\/span><span>\"agents\"<\/span><span>;<\/span><\/div><\/div><div><div>\n<\/div><\/div><div><div><span>export<\/span><span> <\/span><span>class<\/span><span> <\/span><span>MyAgent<\/span><span> <\/span><span>extends<\/span><span> <\/span><span>Agent<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span>  <\/span><span>async<\/span><span> <\/span><span>onStart<\/span><span>()<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span>    <\/span><span>\/\/ Connect via DO binding \u2014 no HTTP, no network overhead<\/span><\/div><\/div><div><div><span>    <\/span><span>await<\/span><span> <\/span><span>this<\/span><span>.<\/span><span>addMcpServer<\/span><span>(<\/span><span>\"counter\"<\/span><span>,<\/span><span> <\/span><span>env<\/span><span>.<\/span><span>MY_MCP<\/span><span>)<\/span><span>;<\/span><\/div><\/div><div><div>\n<\/div><\/div><div><div><span>    <\/span><span>\/\/ With props for per-user context<\/span><\/div><\/div><div><div><span>    <\/span><span>await<\/span><span> <\/span><span>this<\/span><span>.<\/span><span>addMcpServer<\/span><span>(<\/span><span>\"counter\"<\/span><span>,<\/span><span> <\/span><span>env<\/span><span>.<\/span><span>MY_MCP<\/span><span>,<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span><span>      <\/span><\/span><span>props<\/span><span>:<\/span><span> <\/span><span>{<\/span><span> userId<\/span><span>:<\/span><span> <\/span><span>\"user-123\"<\/span><span>,<\/span><span> role<\/span><span>:<\/span><span> <\/span><span>\"admin\"<\/span><span> <\/span><span>},<\/span><\/div><\/div><div><div><span>    <\/span><span>}<\/span><span>)<\/span><span>;<\/span><\/div><\/div><div><div><span>  <\/span><span>}<\/span><\/div><\/div><div><div><span>}<\/span><\/div><\/div><\/code><\/pre>\n<div>\n<div><\/div>\n<\/div>\n<\/figure>\n<\/div><\/div>\n<\/li>\n<li>\n<p>TypeScript<\/p>\n<div>\n<div>\n<figure>\n<pre data-language=\"ts\"><code class=\"language-ts\"><div><div><span>import <\/span><span>{<\/span><span><span> <\/span><span>Agent<\/span><span> <\/span><\/span><span>}<\/span><span> from <\/span><span>\"agents\"<\/span><span>;<\/span><\/div><\/div><div><div>\n<\/div><\/div><div><div><span>export<\/span><span> <\/span><span>class<\/span><span> <\/span><span>MyAgent<\/span><span> <\/span><span>extends<\/span><span> <\/span><span>Agent<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span>  <\/span><span>async<\/span><span> <\/span><span>onStart<\/span><span>()<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span>    <\/span><span>\/\/ Connect via DO binding \u2014 no HTTP, no network overhead<\/span><\/div><\/div><div><div><span>    <\/span><span>await<\/span><span> <\/span><span>this<\/span><span>.<\/span><span>addMcpServer<\/span><span>(<\/span><span>\"counter\"<\/span><span>,<\/span><span> <\/span><span>env<\/span><span>.<\/span><span>MY_MCP<\/span><span>)<\/span><span>;<\/span><\/div><\/div><div><div>\n<\/div><\/div><div><div><span>    <\/span><span>\/\/ With props for per-user context<\/span><\/div><\/div><div><div><span>    <\/span><span>await<\/span><span> <\/span><span>this<\/span><span>.<\/span><span>addMcpServer<\/span><span>(<\/span><span>\"counter\"<\/span><span>,<\/span><span> <\/span><span>env<\/span><span>.<\/span><span>MY_MCP<\/span><span>,<\/span><span> <\/span><span>{<\/span><\/div><\/div><div><div><span><span>      <\/span><\/span><span>props<\/span><span>:<\/span><span> <\/span><span>{<\/span><span> userId<\/span><span>:<\/span><span> <\/span><span>\"user-123\"<\/span><span>,<\/span><span> role<\/span><span>:<\/span><span> <\/span><span>\"admin\"<\/span><span> <\/span><span>},<\/span><\/div><\/div><div><div><span>    <\/span><span>}<\/span><span>)<\/span><span>;<\/span><\/div><\/div><div><div><span>  <\/span><span>}<\/span><\/div><\/div><div><div><span>}<\/span><\/div><\/div><\/code><\/pre>\n<div>\n<div><\/div>\n<\/div>\n<\/figure>\n<\/div><\/div>\n<\/li>\n<\/ul>\n<p>The <code>addMcpServer<\/code> method now accepts <code>string | DurableObjectNamespace<\/code> as the second parameter with full TypeScript overloads, so HTTP and RPC paths are type-safe and cannot be mixed.<\/p>\n<p>Key capabilities:<\/p>\n<ul>\n<li><strong>Hibernation support<\/strong> \u2014 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.<\/li>\n<li><strong>Deduplication<\/strong> \u2014 Calling <code>addMcpServer<\/code> with the same server name returns the existing connection instead of creating duplicates. Connection IDs are stable across hibernation restore.<\/li>\n<li><strong>Smaller surface area<\/strong> \u2014 The RPC transport internals have been rewritten and reduced from 609 lines to 245 lines. <code>RPCServerTransport<\/code> now uses <code>JSONRPCMessageSchema<\/code> from the MCP SDK for validation instead of hand-written checks.<\/li>\n<\/ul>\n<aside>\n<p>Note<\/p>\n<div>\n<p>RPC transport is experimental. The API may change based on feedback. Refer to <a href=\"https:\/\/github.com\/cloudflare\/agents\/issues\/565\" target=\"_blank\">the tracking issue<\/a> for updates.<\/p>\n<\/div>\n<\/aside>\n<h4>Optional OAuth for MCP connections<\/h4>\n<p><code>addMcpServer()<\/code> no longer eagerly creates an OAuth provider for every connection. For servers that do not require authentication, a simple call is all you need:<\/p>\n<ul>\n<li>\n<p>JavaScript<\/p>\n<div>\n<div>\n<figure>\n<pre data-language=\"js\"><code class=\"language-js\"><div><div><span>\/\/ No callbackHost, no OAuth config \u2014 just works<\/span><\/div><\/div><div><div><span>await<\/span><span> <\/span><span>this<\/span><span>.<\/span><span>addMcpServer<\/span><span>(<\/span><span>\"my-server\"<\/span><span>,<\/span><span> <\/span><span>\"https:\/\/mcp.example.com\"<\/span><span>)<\/span><span>;<\/span><\/div><\/div><\/code><\/pre>\n<div>\n<div><\/div>\n<\/div>\n<\/figure>\n<\/div><\/div>\n<\/li>\n<li>\n<p>TypeScript<\/p>\n<div>\n<div>\n<figure>\n<pre data-language=\"ts\"><code class=\"language-ts\"><div><div><span>\/\/ No callbackHost, no OAuth config \u2014 just works<\/span><\/div><\/div><div><div><span>await<\/span><span> <\/span><span>this<\/span><span>.<\/span><span>addMcpServer<\/span><span>(<\/span><span>\"my-server\"<\/span><span>,<\/span><span> <\/span><span>\"https:\/\/mcp.example.com\"<\/span><span>)<\/span><span>;<\/span><\/div><\/div><\/code><\/pre>\n<div>\n<div><\/div>\n<\/div>\n<\/figure>\n<\/div><\/div>\n<\/li>\n<\/ul>\n<p>If the server responds with a 401, the SDK throws a clear error: <code>\"This MCP server requires OAuth authentication. Provide callbackHost in addMcpServer options to enable the OAuth flow.\"<\/code> The restore-from-storage flow also handles missing callback URLs gracefully, skipping auth provider creation for non-OAuth servers.<\/p>\n<h4>Hardened JSON Schema to TypeScript converter<\/h4>\n<p>The schema converter used by <code>generateTypes()<\/code> and <code>getAITools()<\/code> now handles edge cases that previously caused crashes in production:<\/p>\n<ul>\n<li><strong>Depth and circular reference guards<\/strong> \u2014 Prevents stack overflows on recursive or deeply nested schemas<\/li>\n<li><strong><code>$ref<\/code> resolution<\/strong> \u2014 Supports internal JSON Pointers (<code>#\/definitions\/...<\/code>, <code>#\/$defs\/...<\/code>, <code>#<\/code>)<\/li>\n<li><strong>Tuple support<\/strong> \u2014 <code>prefixItems<\/code> (JSON Schema 2020-12) and array <code>items<\/code> (draft-07)<\/li>\n<li><strong>OpenAPI 3.0 <code>nullable: true<\/code><\/strong> \u2014 Supported across all schema branches<\/li>\n<li><strong>Per-tool error isolation<\/strong> \u2014 One malformed schema cannot crash the full pipeline in <code>generateTypes()<\/code> or <code>getAITools()<\/code><\/li>\n<li><strong>Missing <code>inputSchema<\/code> fallback<\/strong> \u2014 <code>getAITools()<\/code> falls back to <code>{ type: \"object\" }<\/code> instead of throwing<\/li>\n<\/ul>\n<h4><code>@cloudflare\/ai-chat<\/code> fixes<\/h4>\n<ul>\n<li><strong>Tool denial flow<\/strong> \u2014 Denied tool approvals (<code>approved: false<\/code>) now transition to <code>output-denied<\/code> with a <code>tool_result<\/code>, fixing Anthropic provider compatibility. Custom denial messages are supported via <code>state: \"output-error\"<\/code> and <code>errorText<\/code>.<\/li>\n<li><strong>Abort\/cancel support<\/strong> \u2014 Streaming responses now properly cancel the reader loop when the abort signal fires and send a done signal to the client.<\/li>\n<li><strong>Duplicate message persistence<\/strong> \u2014 <code>persistMessages()<\/code> now reconciles assistant messages by content and order, preventing duplicate rows when clients resend full history.<\/li>\n<li><strong><code>requestId<\/code> in <code>OnChatMessageOptions<\/code><\/strong> \u2014 Handlers can now send properly-tagged error responses for pre-stream failures.<\/li>\n<li><strong><code>redacted_thinking<\/code> preservation<\/strong> \u2014 The message sanitizer no longer strips Anthropic <code>redacted_thinking<\/code> blocks.<\/li>\n<li><strong><code>\/get-messages<\/code> reliability<\/strong> \u2014 Endpoint handling moved from a prototype <code>onRequest()<\/code> override to a constructor wrapper, so it works even when users override <code>onRequest<\/code> without calling <code>super.onRequest()<\/code>.<\/li>\n<li><strong>Client tool APIs undeprecated<\/strong> \u2014 <code>createToolsFromClientSchemas<\/code>, <code>clientTools<\/code>, <code>AITool<\/code>, <code>extractClientToolSchemas<\/code>, and the <code>tools<\/code> option on <code>useAgentChat<\/code> are restored for SDK use cases where tools are defined dynamically at runtime.<\/li>\n<li><strong><code>jsonSchema<\/code> initialization<\/strong> \u2014 Fixed <code>jsonSchema not initialized<\/code> error when calling <code>getAITools()<\/code> in <code>onChatMessage<\/code>.<\/li>\n<\/ul>\n<h4>Upgrade<\/h4>\n<p>To update to the latest version:<\/p>\n<div>\n<figure>\n<pre data-language=\"sh\"><code class=\"language-sh\"><div><div><span>npm<\/span><span> <\/span><span>i<\/span><span> <\/span><span>agents@latest<\/span><span> <\/span><span>@cloudflare\/ai-chat@latest<\/span><\/div><\/div><\/code><\/pre>\n<div>\n<div><\/div>\n<\/div>\n<\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>The latest release of the Agents SDK lets you define an Agent and an McpAgent in the same Worker and connect them over RPC \u2014 no HTTP, no network overhead. It also makes OAuth opt-in for simple MCP connections, hardens the schema converter for production workloads, and ships a batch of @cloudflare\/ai-chat reliability fixes. RPC [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-251","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts\/251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/comments?post=251"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/posts\/251\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/media?parent=251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/categories?post=251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.securinsight.ca\/index.php\/wp-json\/wp\/v2\/tags?post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}