chore: migrate to MCP TypeScript SDK v2#122
Merged
Merged
Conversation
# Conflicts: # package-lock.json # package.json # src/index.ts # src/server.ts
Replace @modelcontextprotocol/sdk v1 with the v2 packages
@modelcontextprotocol/server and @modelcontextprotocol/client, pinned to
2.0.0-beta.1, re-applied on top of the refactored main (src/tools/*).
- Repoint imports to @modelcontextprotocol/server root export (WebStandard
transport, McpServer, Tool/CallToolResult types).
- Low-level non-codemode handlers use method strings
(setRequestHandler('tools/list'|'tools/call', ...)) since the request
schema exports were removed.
- Wrap registerTool input/output schemas in z.object(...) for the v2
Standard Schema API.
- Mirror v2 wire output in the precomputed artifacts: JSON Schema dialect
2020-12 (was draft-07) and drop execution.taskSupport (v2 omits it).
- Drop the manual @cfworker/json-schema dep (bundled by the beta validator).
- Point the test Client import at @modelcontextprotocol/client.
npm run check passes (261 tests); deployed to staging (boots in 107ms).
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.
Summary
Migrate from
@modelcontextprotocol/sdkv1 to the v2 packages, pinned to the2.0.0-beta.1release candidate. Rebuilt on top of currentmain(whichrefactored the tool code into
src/tools/*).@modelcontextprotocol/sdk; add@modelcontextprotocol/server@2.0.0-beta.1(dep) and
@modelcontextprotocol/client@2.0.0-beta.1(devDep, tests only).@modelcontextprotocol/serverroot export(
WebStandardStreamableHTTPServerTransport,McpServer,Tool/CallToolResulttypes). The Web Standard transport still exists in v2 with the same options, so
src/index.tsis a behavior-preserving import change.(
setRequestHandler('tools/list' | 'tools/call', …)); the request-schemaexports were removed in v2.
registerToolinputSchema/outputSchemainz.object(…)for the v2Standard Schema API.
dialect
2020-12(wasdraft-07) and dropexecution.taskSupport(v2 omits itfor non-task tools). Kept byte-identical to the SDK-generated tools per
tests/non-codemode.test.ts.@cfworker/json-schemadependency:2.0.0-beta.1bundles the Workersvalidator and auto-selects it on the
workerdexport condition.See
MIGRATION_TRACKER.mdfor the full decision log.Validation
npm run check— format, lint, typecheck, and 261 tests pass (incl. the e2esuite that drives the real worker through the full Streamable HTTP transport,
tool dispatch, and a real Worker Loader isolate call against
2.0.0-beta.1).npm run deploy— deployed to staging; worker boots in 107 ms with nobundle/boot errors.
Deployed-worker smoke checks:
/.well-known/oauth-protected-resource→200,/.well-known/oauth-authorization-server→200, unauthenticatedPOST /mcp→401. (A full authenticated round-trip against the staging endpoint needs atoken valid on the staging Cloudflare API; that path is covered by the e2e suite.)
Notes
2.0.0-beta.1is <3 days old, so installing it locally requires overriding themin-release-agenpm setting for the intentional install.