|
| 1 | +--- |
| 2 | +title: Agents SDK v0.2.24 with resumable streaming, MCP improvements, and schedule fixes |
| 3 | +description: This release adds resumable streaming over websockets, enhanced MCP client APIs with connection state observability, improved schedule reliability, and SSE transport enhancements. |
| 4 | +products: |
| 5 | + - agents |
| 6 | + - workers |
| 7 | +date: 2025-11-26 |
| 8 | +--- |
| 9 | + |
| 10 | +The latest release of [@cloudflare/agents](https://github.com/cloudflare/agents) brings resumable streaming, significant MCP client improvements, and critical fixes for schedules and Durable Object lifecycle management. |
| 11 | + |
| 12 | +### Resumable streaming |
| 13 | + |
| 14 | +`AIChatAgent` now supports resumable streaming, allowing clients to reconnect and continue receiving streamed responses without losing data. This is useful for: |
| 15 | + |
| 16 | +- Long-running AI responses |
| 17 | +- Users on unreliable networks |
| 18 | +- Users switching between devices mid-conversation |
| 19 | +- Background tasks where users navigate away and return |
| 20 | +- Real-time collaboration where multiple clients need to stay in sync |
| 21 | + |
| 22 | +Streams are maintained across page refreshes, broken connections, and syncing across open tabs and devices. |
| 23 | + |
| 24 | +### Other improvements |
| 25 | + |
| 26 | +- Default JSON schema validator added to MCP client |
| 27 | +- [Schedules](https://developers.cloudflare.com/agents/api-reference/schedule-tasks/) can now safely destroy the agent |
| 28 | + |
| 29 | +### MCP client API improvements |
| 30 | + |
| 31 | +The `MCPClientManager` API has been redesigned for better clarity and control: |
| 32 | + |
| 33 | +- **New `registerServer()` method**: Register MCP servers without immediately connecting |
| 34 | +- **New `connectToServer()` method**: Establish connections to registered servers |
| 35 | +- **Improved reconnect logic**: `restoreConnectionsFromStorage()` now properly handles failed connections |
| 36 | + |
| 37 | +```ts |
| 38 | +// Register a server to Agent |
| 39 | +const { id } = await this.mcp.registerServer({ |
| 40 | + name: "my-server", |
| 41 | + url: "https://my-mcp-server.example.com", |
| 42 | +}); |
| 43 | + |
| 44 | +// Connect when ready |
| 45 | +await this.mcp.connectToServer(id); |
| 46 | + |
| 47 | +// Discover tools, prompts and resources |
| 48 | +await this.mcp.discoverIfConnected(id); |
| 49 | +``` |
| 50 | + |
| 51 | +The SDK now includes a formalized `MCPConnectionState` enum with states: `idle`, `connecting`, `authenticating`, `connected`, `discovering`, and `ready`. |
| 52 | + |
| 53 | +### Enhanced MCP discovery |
| 54 | + |
| 55 | +MCP discovery fetches the available tools, prompts, and resources from an MCP server so your agent knows what capabilities are available. The `MCPClientConnection` class now includes a dedicated `discover()` method with improved reliability: |
| 56 | + |
| 57 | +- Supports cancellation via AbortController |
| 58 | +- Configurable timeout (default 15s) |
| 59 | +- Discovery failures now throw errors immediately instead of silently continuing |
| 60 | + |
| 61 | +### Bug fixes |
| 62 | + |
| 63 | +- Fixed a bug where [schedules](https://developers.cloudflare.com/agents/api-reference/schedule-tasks/) meant to fire immediately with this.schedule(0, ...) or `this.schedule(new Date(), ...)` would not fire |
| 64 | +- Fixed an issue where schedules that took longer than 30 seconds would occasionally time out |
| 65 | +- Fixed SSE transport now properly forwards session IDs and request headers |
| 66 | +- Fixed AI SDK stream events convertion to UIMessageStreamPart |
| 67 | + |
| 68 | +### Upgrade |
| 69 | + |
| 70 | +To update to the latest version: |
| 71 | + |
| 72 | +```sh |
| 73 | +npm i agents@latest |
| 74 | +``` |
0 commit comments