Adopt the MCP 2026-07-28 spec in the TypeScript server (SDK v2) - #6
Merged
Conversation
Migrates the TypeScript server from @modelcontextprotocol/sdk v1 to @modelcontextprotocol/server v2, which implements the 2026-07-28 protocol revision. Mechanical parts via the official codemod; the rest by hand. Existing users are unaffected: a v2 server is dual-era and still answers the 2025-era `initialize` handshake. That is asserted, not assumed — the new legacy-client test drives the built binary over stdio with a v1 SDK client, the same path Claude Desktop, Cursor and Smithery use. Also in here because the migration could not be verified without them: - zod 3 -> 4 (v2 requires >=4.2), which renamed ZodError.errors to .issues - Node engine >=20, matching what the SDK and CI already require - fixed six pre-existing type errors that `npm run typecheck` had never been run against in CI (unused imports; interfaces returned where a Record<string, unknown> was declared) - split createServer() out of index.ts into server.ts so it can be built and driven in a test without the entry point's side effects - first tests on the TypeScript side at all, and dropped the `continue-on-error: true` that let them fail silently; added typecheck to CI - aligned the version three ways (package.json 0.2.0, code 0.10.0, npm 1.0.1) onto 1.1.0, with a test that fails if they drift again Refs #4 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVnEdm6smNC5ZJzghc7WRY
Merged
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.
Migrates the TypeScript implementation to
@modelcontextprotocol/serverv2, which implements the2026-07-28protocol revision. The mechanical parts came from the official codemod; everything else is by hand.Part of #4. Python is not touched here — it follows in its own PR, as does the multi-database work (#5), which is why the SDK migration goes first: the tool signatures only get rewritten once.
Existing users are not affected, and this proves it
The obvious worry with a revision that drops the
initializehandshake is that every installed client breaks. It does not: a v2 server is dual-era and still answers the legacy handshake, while 2026-capable clients negotiate throughserver/discover.Rather than take the migration guide’s word for it,
src/__tests__/legacy-client.test.tsspawns the builtdist/index.jsas a subprocess over stdio and drives it with a v1 SDK client — the same code path Claude Desktop, Cursor and Smithery use today. It asserts the handshake completes and all 14 tools list.What else is in here, and why
None of this is padding — the migration could not be verified without it:
ZodError.errorsto.issues, which broke config validation.npm run typecheckwas never run in CI, so it had accumulated unused imports and interfaces returned where aRecord<string, unknown>was declared (interfaces carry no implicit index signature). Unrelated to the SDK, buttypecheckhad to pass for the migration to mean anything.typecheckis now a CI step.createServer()split out ofindex.tsintoserver.ts, so a test can build a server without the entry point’s side effects (settings validation,process.exit, stdio connect).continue-on-error: truethat letnpm testfail silently in CI is gone.package.json0.2.0, the code 0.10.0, npm 1.0.1. All now 1.1.0, with a test that fails if they separate again. Pick a different number before publishing if you disagree.Verification
The legacy-client test needs a build first, so
pretestnow runsnpm run build.🤖 Generated with Claude Code
https://claude.ai/code/session_01LVnEdm6smNC5ZJzghc7WRY