feat: add mcp core for protocol versions - #6829
Conversation
🦋 Changeset detectedLatest commit: ddf5e7a The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
43f8843 to
cc06753
Compare
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
ℹ️ Minor suggestions inline — two rough edges worth a look, plus a note on a behavioral change.
Reviewed changes — adds multi-version MCP protocol support through three dated adapters (2024-11-05, 2025-03-26, 2025-06-18) layered over a version-neutral McpCore. Each adapter owns its dated wire schemas, RPC vocabulary, handler projections, content-type encoding, reverse client construction, and transport rules. McpServer delegates all registration and dispatch to the core, while protocol selection and session management stays in the transport layer.
- Three dated wire schemas (
internal/mcpSchema/v20*_*_*.ts) delta-inheriting from predecessor revisions - Three dated protocol adapters (
internal/mcpProtocol/v20*_*_*.ts) declaring throughMcpProtocol.make— handlers, reverse clients, notification projection, and cancellation normalization for each revision - Version-neutral
McpCore(internal/mcpCore.ts) with registration state, dispatch, and semantic error types - Server integration (
McpServer.ts,mcpProtocolRegistry.ts) refactored to install adapter handlers viaHandlerInstallationTargetand select protocol at init RpcSerializationfix excluding notifications from JSON-RPC batch size countingLifecycle.test.tsdeleted (fully replaced byMcpConformance/LifecycleTest.ts, now composed into all three version entrypoints)ProtocolAdapters.test.ts— 1190-line cross-version integration suite exercising projection, encoding, visibility, session isolation, and error paths across all three revisions
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — four fixes from the prior review feedback in commit ddf5e7a:
addResource/addResourceTemplate/addPromptdedup — each now usesfindIndex-by-key replacement matching theaddToolpattern, so re-registering the same URI, template, or prompt name replaces the previous entry instead of pushing a duplicate into the public array getters.findResourceerror behavior restored — unknown URIs now fail withInvalidParams(error code -32602, messageResource '...' not found) instead of silently returning{ contents: [] }.- Test updated — the
findResourceunknown-URI test asserts theInvalidParamserror; also added newdirect servicetest suite covering resource handler failure preservation and omitted-argument passthrough for tool handlers.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

Type
Description
As part of being able to define new protocol adapters, I've added first-class support for multiple MCP protocol revisions based on the existing
McpSchema(<= v2025-06-18):v2024-11-05v2025-03-26v2025-06-18So now an MCP server now declares an ordered list of protocol adapters:
The client’s requested protocol is selected before its payload is decoded. Once initialization succeeds, the selected adapter remains associated with that session.
The main separation is between:
McpCore, which owns version-neutral tools, resources, prompts, completions, notifications, and semantic errorsMcpServer, which owns transport lifecycle, sessions, dispatch, cancellation, and notification deliveryEach dated adapter is declared through
McpProtocol.make:McpProtocol.makederives the repetitive mechanics from this declaration:This keeps version-specific decisions at the adapter boundary instead of introducing revision checks throughout
McpServer.How to Review
There is a lot of code here, but also a lot of duplicated patterns since each dated protocol reimplements its own schema and adaptor. This should make each protocol more resistent to changes as new versions are added, but still adds a lot to look over:
I would suggest starting with the commits as they break up the different parts, but can mostly focus on how the v2025-06-18 works since this is semantically the same as how the
McpSchemacurrently works. The other two are mostly about reducing the capabilities or changing how some behaviour works, but nothing too crazy is added and all the conformance suites have been updated to exclude spec tests that didn't apply to older versions.Related