Make McpAgent extend Agent + Streaming HTTP protocol features#415
Conversation
🦋 Changeset detectedLatest commit: 4e1794f The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| * @returns An error response object with status code and message | ||
| */ | ||
| onError(error: Error): { status: number; message: string } { | ||
| onMcpError(error: Error): { status: number; message: string } { |
There was a problem hiding this comment.
This seems to be a breaking change. The old McpAgent had a custom onError method that clashes with the base Agent method with the same name once we extend it.
commit: |
|
this is some really good stuff! @deathbyknowledge great work |
threepointone
left a comment
There was a problem hiding this comment.
tentative approval pending nits and notes
| onmessage?: (message: JSONRPCMessage) => void; | ||
| sessionId?: string; | ||
| async setInitialized() { | ||
| await this.ctx.storage.put("initialized", true); |
There was a problem hiding this comment.
| await this.ctx.storage.put("initialized", true); | |
| // todo: move to sync api once https://github.com/cloudflare/workerd/pull/4895 lands | |
| await this.ctx.storage.put("initialized", true); |
c26e919 to
969371c
Compare
|
How confident are we that this is going to be merged? Can I safely prepare teaching material based on this PR? |
We're waiting to release the AI SDK v5 changes to merge this. Should land this week |
|
That is helpful context. Do you have an idea/recommendation for getting:
I know that the |
The comment I left here #426 (comment) should cover all of those |
|
Just saw your message on my PR: #426 (comment) Thanks for that! So I take it from your message that it is fine/encouraged/recommended for me to modify |
|
It is fine in the context of |
|
Sounds good. Thank you for your help! |
|
That still needs to be thought out, it might not be directly though an |
|
That's fine. Just my 2¢, I think it would be good for the ecosystem if Cloudflare's implementation either supported the full TypeScript SDK (preferred) or built its own. Supporting part of the SDK will lead to confusion for folks I think. |
|
LFG |

Lib changes:
McpAgentnow extends the baseAgentclass extend McpAgent from Agent #235Agentand PartykitServerprimitives. Depends on Allow routing ctx props to Server partykit#268Tests:
@modelcontextprotocol/sdk. They include authless and OAuth MCP examples.Streamable HTTP changes adapted from the TS SDK
Run the E2E from
/packages/agentswith