Use public Protocol with isolated SDK role peers - #5
Draft
tonxxd wants to merge 6 commits into
Draft
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 is the official Protocol + role-isolated peers alternative to #4.
It starts from Andrew's PR modelcontextprotocol#710 head (
f50ec6e) and replaces the temporary Client/Server inheritance on the iframe channel with the public v2Protocolbase restored by modelcontextprotocol/typescript-sdk#2501. Unlike #4, it does not maintain a local JSON-RPC protocol implementation.The package remains a single npm package, but its entry points no longer have cross-role runtime or declaration edges:
.,./react, and./app-bridgeuse the client package./serveruses the server packageDependency shape
Before (modelcontextprotocol#710)
A server-only consumer therefore acquired both SDK roles.
This PR
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 --> CoreWhy this alternative
Compared with #4:
The iframe wire flow remains Apps-specific:
There is no additional standard MCP
initializehandshake on the iframe channel.Implementation
AppandAppBridgeto the official publicProtocol<BaseContext>.app.ts, eliminating the server-to-app runtime edge.@modelcontextprotocol/coreschemas.distbefore building to prevent stale entry-point artifacts from being packed.Upstream dependency status
modelcontextprotocol/typescript-sdk#2501 was merged on July 17, after
2.0.0-beta.4was published. Per the maintainer's comment on #712, the public Protocol base will be available in the next beta.For review, this draft uses the maintainer's
pkg.pr.newartifacts for #2501. Before merge, replace those preview specifications with the next published beta and regenerate the lockfile.Verification
Passed:
npm run buildnpm run build:all(all example workspaces)npm test— 392 passed, 1 skippednpm run test:dependency-isolationgit diff --checkThe full local Playwright run completed all 84 cases but was not green: visual goldens differed consistently in this macOS rendering environment, and the PDF group was timing-sensitive. No snapshots are updated in this PR. CI's Linux run should be treated as authoritative for those environment-sensitive checks.
Scope
This draft does not modify Andrew's branch or PR modelcontextprotocol#710 directly. It is intended for comparing the official-Protocol/role-peer design with the core-only design in #4.