feat: add v2026-07-28 protocol adapter - #7265
Conversation
🦋 Changeset detectedLatest commit: 96e534e 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 |
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
70450e1 to
efcac61
Compare
efcac61 to
dc63469
Compare
dc63469 to
8066084
Compare
8066084 to
360788f
Compare
360788f to
96e534e
Compare
IMax153
left a comment
There was a problem hiding this comment.
@lloydrichards - honestly this looks pretty good to me. The example you provided is quite nice for describing an MCP server.
What is our current test coverage with the 2026-07-28 features? Do we cover the entire spec? Or are we missing pieces currently.
| description: tool.description, | ||
| inputSchema: tool.inputSchema, | ||
| outputSchema: tool.outputSchema, | ||
| outputSchema: Schema.is(McpSchema.Tool.fields.outputSchema)(tool.outputSchema) |
There was a problem hiding this comment.
These schema compilers should be extracted to layer / module scope where possible to avoid re-compiling every time.
|
@lloydrichards you are a legend, thank you so much! |
Type
Description
Add support the
McpProtocol.v2026_07_28which introduced the 'modern' stateless mcp architecture, while still supporting the previous session-based protocol versions. To support both lifecycles, we extract the protocol lifecycle handling into dedicated runtimes.McpServerselects the appropriate runtime for each adapter: older adapters keep their stateful initialization and session behavior, whilev2026_07_28selects and decodes the protocol from each request without creating session state.The main user-facing additions are:
server/discovernegotiation, with no initialization handshake or session state.McpRequestContextgives handlers access to request and client capabilities neutral to the runtime of the protocol.McpSchema.InputRequired, and clients can provide keyed elicitation, sampling, or roots responses on a later request.subscriptions/listen, delivering filtered server change notifications over stdio or Server-Sent Events.structuredContentfor every JSON value in the 2026-07-28 adapter. Earlier adapters continue to project only the shapes they support.A toy example of the stateless server and JSON tool output:
It wasn't possible to model a purely incremental session-era adapter due to the runtime changes, so this PR introduces a few structural changes to both Mcp and Rpc:
ProtocolAdaptersnow declare whether they use a stateful or stateless lifecycle policy.McpServerowns lifecycle runtime state, separating the existing sessionful path from the 2026-07-28 request-scoped path.McpRequestContext; legacy reverse operations continue to useMcpServerClient.Supporting
subscriptions/listenrequired a reusable RPC transport api for streaming responses and typed server-to-client notifications. The RPC change adds on top of the existing buffered HTTP behavior, while MCP can opt into streaming responses and notifications.How to Review
The files that deserve the most scrutiny should be:
mcpProtocol/v2026_07_28.ts+mcpSchema/v2026_07_28.ts-> dated wire behaviormcpRuntime.ts+mcpStatefulRuntime.ts-> stateless and preserved session lifecyclesRpcServer.ts-> streaming HTTP responses and notificationsBut its probably going to be easiest to just go through each commit ad there is a clear set of packages of work across each:
1. Runtime extraction
refactor: introduce MCP lifecycle runtimes and request contextExtracts the lifecycle ownership from the protocol adapters into
McpServerruntimes.This separates the existing sessionful protocol path from the new stateless path without retrofitting sessions onto 2026-07-28. It also introduces
McpRequestContext, allowing common handlers to read per-request protocol, capability, and client facts while legacy reverse operations keep usingMcpServerClient.2. Adding v2026-07-28
feat: add MCP 2026-07-28 protocol adapterAdds the dated wire schemas and adapter for MCP
2026-07-28.The adapter is selected from raw HTTP headers and request
_metabefore dated payload decoding. It servesserver/discover, requires self-contained routing metadata, and deliberately creates or consults noMcp-Session-Idstate.3. Adding MRTR
feat: support MCP multi-round-trip tool resultsAdds multi-round-trip tool results (MRTR).
Tool handlers can return
McpSchema.InputRequiredto ask for keyed elicitation, sampling, or roots input. A later self-contained request provides the corresponding responses throughMcpRequestContext, preserving the stateless model rather than holding a reverse-RPC session open.4. Adding subscriptions
feat: support RPC HTTP streaming and server notificationsfeat: add MCP 2026-07-28 subscriptionsFirst adds the transport primitive: request-selected streaming HTTP responses and typed server-to-client notifications for HTTP and stdio.
The protocol layer then uses that primitive for
subscriptions/listen, which delivers filtered MCP change notifications over SSE or stdio without changing legacy notification behavior.5. Clean up and compatibility hardening
feat: support JSON-valued MCP tool outputstest: organize MCP conformance suites by protocol behaviorfix: make MCP list-change scheduling deterministicFinishes the user-facing output model and makes version compatibility explicit:
structuredContentfor any JSON value; earlier adapters project only the shapes they support.Related