Repository navigation
feat(cloudflare): Drop the legacy MCP SDK transport from chat routes - #1924
Merged
Merged
Conversation
The web chat and metadata routes still imported the v1 `@modelcontextprotocol/sdk` just for `StreamableHTTPClientTransport`, long after the server moved to SDK v2. That pulled a second copy of the MCP spec schemas into the worker and built ~1,000 extra zod schemas on every isolate start. `@ai-sdk/mcp` already ships an http transport that takes a url and headers, so use that and drop the dependency. Also removes the vitest ajv stub, which only existed because the legacy SDK imported ajv. Worker bundle drops ~119 KiB and local startup CPU goes from ~61ms to ~54ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
scttcper
marked this pull request as ready for review
November 4, 2026 00:53
BYK
approved these changes
Nov 4, 2026
7 tasks done
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The web chat and metadata routes still imported the v1
@modelcontextprotocol/sdkjust forStreamableHTTPClientTransport. #1731 removed v1 from mcp-core but the worker kept this one import, which pulls a second copy of the MCP spec schemas into the bundle and builds them on every isolate start.@ai-sdk/mcpalready has a built-in http transport that takes a url and headers, so this uses that and drops the dependency (and the vitest ajv stub that only existed for the legacy SDK).wrangler check startup, local median)Startup numbers are local workerd runs, production cpus are slower so the absolute ms will be higher there.
Why it's safe:
/api/chatand/api/metadatause this client. The/mcpendpoint agents connect to is unchanged.@ai-sdk/mcpclient is the same, only the transport underneath it changed.whoami,find_organizations,find_projects) through both the old and new transport. Same 72 tools listed, identical results for every call.HTTP 401, so that still triggers. The old one only matched when the response body happened to say "access token", so it also missed the "Token audience does not match resource server" case.