Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .changeset/brave-doors-glow.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/calm-pens-juggle.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/codemode-validate-tool-args.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/expose-request-id.md

This file was deleted.

8 changes: 0 additions & 8 deletions .changeset/five-cities-raise.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/fix-ai-chat-abort-cancel.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/fix-jsonschema-init.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/fix-redacted-thinking.md

This file was deleted.

15 changes: 0 additions & 15 deletions .changeset/harden-schema-converter.md

This file was deleted.

11 changes: 0 additions & 11 deletions .changeset/lazy-mcp-oauth.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/petite-walls-invite.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/rpc-experimental-warning.md

This file was deleted.

44 changes: 0 additions & 44 deletions .changeset/rpc-transport-rewrite.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/silver-dryers-run.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/ten-llamas-exist.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/undeprecate-client-tools.md

This file was deleted.

10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions packages/agents/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,73 @@
# @cloudflare/agents

## 0.6.0

### 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.

## 0.5.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"durable objects"
],
"type": "module",
"version": "0.5.1",
"version": "0.6.0",
"license": "MIT",
"repository": {
"directory": "packages/agents",
Expand Down
Loading