Repository navigation
M4: multi-round-trip requests and subscriptions/listen - #5
Merged
Merged
Conversation
Server: - Request-McpElicitation (form and URL mode), Request-McpSampling and Request-McpRoot answer tools/call, prompts/get and resources/read with an InputRequiredResult; -Defer and Wait-McpInput batch several inputs per round. - requestState signed with HMAC-SHA256 and bound to method, target, argument digest and expiry; it accumulates answers of earlier rounds and the handler's $Context.State (New-McpServer -RequestStateKey, -RequestStateTtlSeconds). State is verified before inputResponses; failures answer -32602. Missing client capabilities answer -32021 with data.requiredCapabilities. - subscriptions/listen: acknowledgement first, subscription id on every notification, strict filter, resource updates for sub-resources, SSE stream per listen request over HTTP, stdio cancel, graceful close on shutdown. - Send-McpToolListChanged/-PromptListChanged/-ResourceListChanged, Send-McpResourceUpdated; Register-* on a running server and the new Unregister-McpTool/-Resource/-Prompt notify subscribers, and late handlers are defined in the workers on first use. listChanged/subscribe declared as true. Client: - Connect-McpServer -OnElicitation/-OnSampling/-OnRoots/-MaxInputRounds; the retry loop echoes requestState verbatim and omits it when none was sent. - Register-McpSubscription, Unregister-McpSubscription, Receive-McpNotification with background readers (stdio/in-memory inbox pump, one reader per HTTP stream with reconnect), cache invalidation and -Action callbacks. Conformance: server baseline empty; client baseline holds only M6 auth. Docs: MRTR and subscriptions concepts, roadmap (exit scenarios corrected to server-stateless), changelog, README, about help, examples/elicitation-server.ps1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ATyZ6eV1KJ8g6koeUnCdcE
A worker enqueues its response before its invocation completes, and the dispatcher removed the in-flight entry only after the worker finished. A client that reused the id right after the response (as JSON-RPC allows) could hit the duplicate-id check and get -32600, which made the Mcp-Param header test in the HTTP suite fail intermittently. An answered or cancelled entry now moves to a private key when its id arrives again; Update-McpInFlightRequest still disposes its worker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ATyZ6eV1KJ8g6koeUnCdcE
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 implements milestone M4 from ROADMAP.md: multi-round-trip requests (MRTR) and
subscriptions/listen, on both the server and the client side.Server: MRTR
Request-McpElicitation, in form mode (flat primitive schema subset) or URL mode.Request-McpSamplingandRequest-McpRoot.-Defertogether withWait-McpInputasks for several inputs in a single round.InputRequiredResult; on the retry the handler runs again from the start and gets the answer.requestStateis signed with HMAC-SHA256 and bound to the method, the target, a digest of the arguments and an expiry. It carries the answers of earlier rounds and$Context.State. It is configured withNew-McpServer -RequestStateKeyand-RequestStateTtlSeconds.inputResponses. A bad state or malformed answers fail with-32602. An input type the client did not declare fails with-32021anddata.requiredCapabilities.tools/call,prompts/getandresources/read.Server: subscriptions
subscriptions/listensends the acknowledgement first, tags every notification with the subscription id and applies the filter strictly.resources/updatedalso covers sub-resources of a subscribed URI.notifications/cancelledends a subscription. When the server stops, every open subscription gets acompleteresult.Send-McpToolListChanged,Send-McpPromptListChanged,Send-McpResourceListChangedandSend-McpResourceUpdated.Register-*on a running server and the newUnregister-McpTool,Unregister-McpResourceandUnregister-McpPromptnotify subscribers.listChangedandresources.subscribeare now declared astrue.Client
Connect-McpServergains-OnElicitation,-OnSampling,-OnRootsand-MaxInputRounds.requestStateback unchanged, and leaves it out when the server sent none.Register-McpSubscription,Unregister-McpSubscriptionandReceive-McpNotification:-Actioncallbacks run in the caller's runspace.Connect-McpServer -Servernow fails immediately for a server object that is already running, instead of waiting for the discover timeout.Conformance (
@modelcontextprotocol/conformance@0.2.0-alpha.11, requirement set 2026-07-28, run locally)input-required-result-*scenarios pass.subscriptions/listenchecks inserver-statelesspass: ack, subscription id, filter, tools and prompts list changes.sep-2322-client-request-statepasses (5/5). The only remaining baseline entries are the M6 authorization scenarios.server-sse-multiple-streamsas an M4 exit scenario. That scenario does not testsubscriptions/listen(it was already green); the listen checks are inserver-stateless. Both documents are corrected.Deliberate limitations
requestStateis signed but not encrypted. AES-GCM encryption and binding to the authenticated principal are recorded under M6.resources/subscribe) come with M5.Docs
docs/concepts/subscriptions.md; rewrittendocs/concepts/mrtr.md.docs/conformance.md,docs/development.mdanddocs/concepts/server-primitives.md.examples/elicitation-server.ps1.Checklist
./build.ps1 -Task CIpasses locally. Run locally: Analyze (no findings) and the full Pester suite underSet-StrictMode -Latest(495 passed, 0 failed, 5 skipped). Package and PublishLocal were not run locally because the PowerShell Gallery is blocked in the sandbox; CI covers them.RequestState.Tests.ps1,InputRequest.Tests.ps1.InputRequests.Tests.ps1(raw wire, in-memory client, HTTP),Subscriptions.Tests.ps1(raw wire, in-memory client, HTTP SSE), and stdio tests against the elicitation example.CHANGELOG.mdhas an entry under[Unreleased]conformance-baseline.ymlshrank (the whole M4 block removed on both sides)🤖 Generated with Claude Code
https://claude.ai/code/session_01ATyZ6eV1KJ8g6koeUnCdcE
Generated by Claude Code