Skip to content

DX-2941: chore: migrate to MCP TypeScript SDK v2 - #23

Open
CahidArda wants to merge 3 commits into
mainfrom
DX-2941-mcp-sdk-v2
Open

DX-2941: chore: migrate to MCP TypeScript SDK v2#23
CahidArda wants to merge 3 commits into
mainfrom
DX-2941-mcp-sdk-v2

Conversation

@CahidArda

@CahidArda CahidArda commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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

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.
@linear-code

linear-code Bot commented Aug 19, 2026

Copy link
Copy Markdown

DX-2941

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and serveStdio.
  • 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.

Comment thread src/index.ts
Comment thread src/server.ts Outdated
registerTool accepts any Standard Schema, so asserting z.ZodObject only
silenced the compiler check without being required to typecheck.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants