feat: port to SDK v2 via concrete Protocol (typescript-sdk#1891)#614
Draft
felixweinberger wants to merge 3 commits intomainfrom
Draft
feat: port to SDK v2 via concrete Protocol (typescript-sdk#1891)#614felixweinberger wants to merge 3 commits intomainfrom
felixweinberger wants to merge 3 commits intomainfrom
Conversation
- import paths sdk/* → @modelcontextprotocol/{client,server}
- events.ts: ProtocolWithEvents extends Protocol (concrete), v1-schema-shim setRequestHandler
- request/notification call-shape transforms (perl)
- drop assert*Capability overrides (Protocol no longer abstract)
- server/index.ts copied from #612 port
- tsconfig: exclude *.examples.ts, docs/ (same as #612)
NOT YET: *Schema imports → specTypeSchema(), request() visibility, ~225 tsc errors remain
- events.ts: ProtocolWithEvents extends Protocol (concrete); v1-compat
envelope-schema overload extracts method+params from .shape and forwards
to v2's 3-arg form. Typed via EnvelopeRequestHandler/ParamsOf<T>.
Event dispatcher writes _notificationHandlers directly to preserve the
v1 sync-dispatch contract (v2's await parseSchema introduces a microtask).
- sdk-schemas.ts (new): envelope/result stubs for SDK *Schema constants
via specTypeSchema(); typed Env<M,P> so ParamsOf infers concretely.
- app.ts/app-bridge.ts: redirect *Schema imports to ./sdk-schemas;
delete no-op assert*Capability overrides; convert this.request({method,
params}, Schema) → this.request('method', params, Schema); autowire
block uses client.callTool/listResources/etc + 2-arg setNotificationHandler.
- generate-schemas.ts: emit z.custom<T>(isSpecType('T', v)) for SDK
external types instead of importing dropped *Schema constants.
- message-transport.ts: JSONRPCMessageSchema → parseJSONRPCMessage.
- server/index.test.ts: Pick<McpServer> → as McpServer.
tsc 0, build 0, npm test 276/2/0. app-bridge.test.ts: 88/88 pass.
9 tasks
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.
DO NOT MERGE — proof-of-concept port to SDK v2 using concrete
Protocol(typescript-sdk#1891). CI is expected to fail (package.jsondepends on localfile:/tmp/*.tgzSDK builds).Supersedes #612 (the composition approach using #1846/#1868). Comparison:
app-bridge.test.tstests unmodifiedProtocolWithEventsDepends on:
Protocol)specTypeSchema)Motivation and Context
Validates that exporting concrete
Protocol(typescript-sdk#1891) yields a much smaller v2 migration than thesetCustom*/extension()path.ProtocolWithEvents extends Protocolpreserved;events.tsshim accepts v1 envelope-schema shape and forwards to v2's 3-arg form.How Has This Been Tested?
Locally: tsc 0,
npm run build0,npm test276/2/0.Breaking Changes
Same scope as #612 — see
BREAKING.md(much smaller).Types of changes
Checklist