Migrate to SDK v2 with official Protocol and isolated role peers#720
Draft
tonxxd wants to merge 10 commits into
Draft
Migrate to SDK v2 with official Protocol and isolated role peers#720tonxxd wants to merge 10 commits into
tonxxd wants to merge 10 commits into
Conversation
Replaces the Client/Server subclassing from the v2 migration with direct Protocol extension, now that the SDK exports Protocol from the client package root. This restores the v1 wire contract on the iframe channel: ui/initialize is the first and only handshake, so deployed hosts keep working unchanged. Deleted with the double handshake: the inner MCP initialize round-trip and its pinned protocol version, the contentless inner capabilities and their retro-registration plumbing, the oninitialized defineProperty shadow, and the getCapabilities/getHostCapabilities split (v1 getCapabilities restored). Tests pin the wire order and assert no MCP initialize is sent in either direction. Note: package.json overrides point the SDK packages at locally built tarballs carrying the Protocol export; replace with published versions before any upstream PR.
The Protocol-based migration needs the Protocol class exported from the package roots, which lands in modelcontextprotocol/typescript-sdk#2501. Pin the preview builds so the branch is installable; swap to the next published beta once that PR is released.
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
This PR brings @khandrew1 SDK v2 migration from #710 upstream together with Felix's public-
Protocolport and the role-isolated optional peers alternativeProblem
The migration to SDK v2 makes both role packages peers of one ext-apps package. A server entry point also imported constants through
app.ts, creating a server → app → client edge.Proposed architecture
This alternative reuses the official public
Protocolbase while isolating each entry point to its matching optional role peer.flowchart TB subgraph ClientSide["App / host entry points"] AppEntry[". / react"] -. "optional peer" .-> Client["@modelcontextprotocol/client"] BridgeEntry["app-bridge"] -. "optional peer" .-> Client end subgraph ServerSide["Server entry point"] ServerEntry["server"] -. "optional peer" .-> Server["@modelcontextprotocol/server"] end AppEntry --> Core["@modelcontextprotocol/core"] BridgeEntry --> Core ServerEntry --> CoreImplementation
AppandAppBridgeto the officialProtocol<BaseContext>.ui/initializehandshake used by v1 hosts.distbefore builds so stale role edges cannot enter published packages.Upstream SDK status
The public
Protocolexport was merged in typescript-sdk#2501 after2.0.0-beta.4was published. Per the maintainer's note, it will be in the next beta.This draft temporarily uses the
pkg.pr.newartifacts for #2501. Before merge, replace those preview specifications with the next published beta and regenerate the lockfile.Tradeoff
This keeps request lifecycle, cancellation, validation, and transport behavior in the official SDK. Consumers still install the one role package used by their entry point. The core-only alternative in #719 avoids both role packages but owns more protocol code in ext-apps.
Verification
npm run buildnpm run build:allnpm test: 392 passed, 1 skippedgit diff --check