Skip to content

feat: port to SDK v2 via concrete Protocol (typescript-sdk#1891) - #614

Closed
felixweinberger wants to merge 2 commits into
mainfrom
fweinberger/v2-protocol-concrete
Closed

feat: port to SDK v2 via concrete Protocol (typescript-sdk#1891)#614
felixweinberger wants to merge 2 commits into
mainfrom
fweinberger/v2-protocol-concrete

Conversation

@felixweinberger

Copy link
Copy Markdown

DO NOT MERGE — proof-of-concept port to SDK v2 using concrete Protocol (typescript-sdk#1891). CI is expected to fail (package.json depends on local file:/tmp/*.tgz SDK builds).

Supersedes #612 (the composition approach using #1846/#1868). Comparison:

#612this PR
Files changed10520
v1 app-bridge.test.ts tests unmodified73/8881/88
Wire-method renames20
v1↔v2 interop shimsneedednot needed
ProtocolWithEventsreplacedkept

Depends on:

Motivation and Context

Validates that exporting concrete Protocol (typescript-sdk#1891) yields a much smaller v2 migration than the setCustom*/extension() path. ProtocolWithEvents extends Protocol preserved; events.ts shim accepts v1 envelope-schema shape and forwards to v2's 3-arg form.

How Has This Been Tested?

Locally: tsc 0, npm run build 0, npm test 276/2/0.

Breaking Changes

Same scope as #612 — see BREAKING.md (much smaller).

Types of changes

  • Breaking change

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Comment threadsrc/app-bridge.ts Fixed
@felixweinberger
felixweinbergerforce-pushed the fweinberger/v2-protocol-concrete branch from fee6d58 to 6247719CompareApril 17, 2026 14:34
Ports ext-apps to @modelcontextprotocol/sdk ^2.0.0-alpha.2 using the v2
backwards-compat layer. Source delta is 4 files +44/-31; the compat layer
keeps v1 deep-import paths and the ZodSchema overloads working.
Unavoidable changes:
- Protocol<X,Y,Z> -> Protocol<ContextT> generic-arity (events.ts)
- assertCapability* override params widened to string (app.ts, app-bridge.ts)
- registerAppTool callback unifies LegacyToolCallback | ToolCallback to
cover both raw-shape and StandardSchema args (server/index.ts)
CI will fail until @modelcontextprotocol/sdk@2.0.0-alpha.2 is published;
see typescript-sdk milestone v2.0.0-bc. package-lock.json intentionally
not updated in this commit.
@felixweinberger
felixweinbergerforce-pushed the fweinberger/v2-protocol-concrete branch from 6247719 to d88ef47CompareApril 17, 2026 14:56
events.ts: convert property-override arrow functions to method overrides
with declared overload signatures. The overrides now expose only the
ZodSchema form (the only one this package uses); a guard skips tracking
during super() construction (Protocol's ctor registers built-in handlers
before our fields initialize). Adds _methodOf() helper, removes the
MethodSchema local type and the eslint-disable directives.
server/index.ts: split registerAppTool into two public overloads
(StandardSchemaWithJSON and ZodRawShape forms) matching registerTool's,
removing the union-args casts. The impl signature still loses the
overload pairing, so the forwarding call into registerTool uses one
@ts-expect-error in place of three casts. Re-export LegacyToolCallback
alongside ToolCallback.
Sign up for freeto 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.

1 participant

@felixweinberger