DX-2941: chore: migrate to MCP TypeScript SDK v2 - #23
Open
CahidArda wants to merge 3 commits into
Open
Conversation
Replace the monolithic @modelcontextprotocol/sdk v1 with the v2 packages (@modelcontextprotocol/server, @modelcontextprotocol/node) and upgrade to zod v4, which v2 requires. The Node-native StreamableHTTPServerTransport is gone in v2, so HTTP serving now goes through createMcpHandler wrapped in toNodeHandler, and stdio uses serveStdio. Both are factory-based, preserving the per-request server instances and stateless behaviour. zod v4 serialises unions of literals as verbose anyOf/const where v1 emitted compact enums, so the plain literal unions become z.enum to keep tool schemas unchanged for clients. Node floor moves to 20+, as required by the v2 packages.
hono is an optional peer of @modelcontextprotocol/node and is never imported by the toNodeHandler path; the runtime dependency is @hono/node-server, which ships as a regular dependency.
There was a problem hiding this comment.
Pull request overview
Migrates this MCP server from the v1 monolithic @modelcontextprotocol/sdk package to the v2 split packages (@modelcontextprotocol/server, @modelcontextprotocol/node), upgrades to Zod v4, and updates the HTTP/stdin serving approach to match the v2 runtime entrypoints.
Changes:
- Replace v1 SDK imports/transport usage with v2
McpServer,createMcpHandler/toNodeHandler, andserveStdio. - Upgrade to Zod v4 and adjust tool schemas (e.g.,
z.enum,z.record(key, value)) to keep client-visible schemas stable. - Raise the Node.js baseline to 20+ and align build output target accordingly.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tsup.config.ts | Align build target with Node 20 baseline. |
| src/tools/redis/db.ts | Convert literal unions to z.enum for stable tool schema output under Zod v4. |
| src/tools/redis/backup.ts | Convert literal union to z.enum for stable tool schema output under Zod v4. |
| src/tools/qstash/qstash.ts | Update z.record usage to the Zod v4-friendly signature. |
| src/tools/helpers.ts | Update generic constraints to Zod v4 types. |
| src/tools/box/snapshots.ts | Update z.record usage to the Zod v4-friendly signature. |
| src/tools/box/manage.ts | Update z.record usage to the Zod v4-friendly signature. |
| src/tool.ts | Switch tool result typing to v2 CallToolResult. |
| src/server.ts | Update server import + tool registration for v2 registerTool API. |
| src/index.ts | Switch HTTP + stdio serving to v2 handler/factory entrypoints. |
| package.json | Swap v1 SDK for v2 packages, upgrade to Zod v4, enforce Node >=20. |
| bun.lock | Lockfile updates reflecting dependency migrations/upgrades. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
registerTool accepts any Standard Schema, so asserting z.ZodObject only silenced the compiler check without being required to typecheck.
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.
Replace the monolithic @modelcontextprotocol/sdk v1 with the v2 packages (@modelcontextprotocol/server, @modelcontextprotocol/node) and upgrade to zod v4, which v2 requires.
The Node-native StreamableHTTPServerTransport is gone in v2, so HTTP serving now goes through createMcpHandler wrapped in toNodeHandler, and stdio uses serveStdio. Both are factory-based, preserving the per-request server instances and stateless behaviour.
zod v4 serialises unions of literals as verbose anyOf/const where v1 emitted compact enums, so the plain literal unions become z.enum to keep tool schemas unchanged for clients.
Node floor moves to 20+, as required by the v2 packages.
https://github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/migration/upgrade-to-v2.md