Migrate to MCP TypeScript SDK v2 packages - #339
Open
Kayaba-Attribution wants to merge 1 commit into
Open
Conversation
The monolithic `@modelcontextprotocol/sdk` was split into scoped packages at 2.0.0 (`@modelcontextprotocol/server`, `client`, `core`, `node`, ...), and the 1.x line is frozen at 1.30.0. This moves the server onto the v2 packages. Generated with the SDK's official codemod (`npx @modelcontextprotocol/codemod@latest v1-to-v2 .`), which reported no unresolvable sites, then hand-adjusted to match the repo's import style (single quotes, no semicolons) rather than reformatting whole files. - `@modelcontextprotocol/sdk` -> `@modelcontextprotocol/server` + `@modelcontextprotocol/node` - `StreamableHTTPServerTransport` -> `NodeStreamableHTTPServerTransport` - `JSONRPCResponse` -> `JSONRPCResultResponse` - `setRequestHandler(ListToolsRequestSchema, ...)` and `setRequestHandler(CallToolRequestSchema, ...)` now take the method string (`'tools/list'`, `'tools/call'`), so the schema imports are no longer needed - zod moved to `^4.2.0`, which the v2 packages require (>= 4.2.0). This repo references zod in one commented-out line, so nothing else changes This is an SDK-package migration only; it does not adopt protocol revision 2026-07-28. Per the SDK's migration guide, v2 keeps speaking the 2025-era protocol unless a server explicitly opts in via `createMcpHandler`, so the existing sessionful Streamable HTTP setup in `scripts/start-server.ts` continues to work unchanged.
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.
Description
The MCP TypeScript SDK split the monolithic
@modelcontextprotocol/sdkinto scoped packages at 2.0.0 (@modelcontextprotocol/server,client,core,node,hono,fastify). The 1.x line is frozen at 1.30.0 on npm. This PR moves the server onto the v2 packages.I generated it with the SDK's own codemod (
npx @modelcontextprotocol/codemod@latest v1-to-v2 .), which reported no unresolvable sites for this repo, then hand-adjusted the touched import lines to match the repo's style (single quotes, no semicolons). Deliberately did not run a formatter across the files, since there is no prettier/eslint config here and doing so rewrote ~2,000 lines of unrelated formatting; the source diff is 27 lines across 4 files instead.Changes:
@modelcontextprotocol/sdk->@modelcontextprotocol/server+@modelcontextprotocol/nodeStreamableHTTPServerTransport->NodeStreamableHTTPServerTransportJSONRPCResponse->JSONRPCResultResponsesetRequestHandler(ListToolsRequestSchema, …)/(CallToolRequestSchema, …)now take the method string ('tools/list','tools/call'), so those schema imports are dropped^4.2.0, which the v2 packages require (>= 4.2.0). This repo references zod in a single commented-out line inopenapi/parser.ts, so nothing else is affected by the major bump.The
package-lock.jsonshrinks substantially because v1's monolithic SDK pulled in express/cors and the OAuth-server pieces that the split packages no longer include.Scope: this does not adopt protocol revision 2026-07-28
Worth being explicit, since the SDK version bump and the new protocol revision landed together but are separate migrations. Per the SDK's migration guide, "nothing in v2 puts a 2026-07-28 byte on the wire by default" — serving the new revision is an explicit opt-in via
createMcpHandler. So the existing sessionful Streamable HTTP setup inscripts/start-server.ts(themcp-session-idmap andsessionIdGenerator) keeps working exactly as it does today, and no client behaviour changes. Adopting the new revision would be a separate, larger change and I have not attempted it here.How was this change tested?
Ran the full CI sequence from
.github/workflows/ci.ymllocally:npm ci— exit 0 (lockfile in sync)npm run build— exit 0npm test— 109 passed across 12 test files, no failuresNot manually exercised against a live Notion workspace, so a smoke test of the stdio and Streamable HTTP entry points against real credentials is worth doing before merge.
Screenshots
n/a