Repository navigation
Conversation
Signed-off-by: King Star <[email protected]>
…s HTTP request exchanges Brings modelcontextprotocol#264 onto the modelcontextprotocol#254 branch so its exchange-scoped id routing can be verified against this branch's regression tests. Sources are the PR's head e14ef60, unmodified.
…lcontextprotocol#264, jstar0) Manifest entry 1. Upstream refs/pull/264/head at e14ef60, unmodified. Fixes modelcontextprotocol#254 and modelcontextprotocol#265.
…rotocol#264 Manifest entry 1a. Tests-only, stacked on pr/264 at e14ef60; offered upstream alongside modelcontextprotocol#264.
…fest entries 1 and 1a
…tream modelcontextprotocol#260, rebased onto modelcontextprotocol#264) Manifest entry 2. Upstream refs/pull/260/head b5da0ef (branch pr/260), rebased onto modelcontextprotocol#264 as 12b8c92 with the cancellation routed through the exchange table. Fixes modelcontextprotocol#255.
…otocol#264) as manifest entry 2
…ests without a reply (upstream modelcontextprotocol#298, EhsanAzish80) Supersedes the contributions of modelcontextprotocol#264, modelcontextprotocol#260 and modelcontextprotocol#270 (manifest entries 1-3), which modelcontextprotocol#298 combines. Conflicts resolved in favour of modelcontextprotocol#298 in HTTPServerTypes.swift, StatelessHTTPServerTransport.swift, Server.swift, CancellationTests.swift and HTTPServerTransportTests.swift. Fork changes re-applied on top: - modelcontextprotocol#258's Server.init description/websiteUrl/icons parameters - modelcontextprotocol#221's MockTransport receiveCallCount / finishStream - entry 1a's collision regression tests and their makeStatelessPOSTRequest authorization overload Behavior: a cancelled original POST now ends as HTTP 200 with an empty text/event-stream and no JSON-RPC body (previously -32002 from modelcontextprotocol#260). Follow-up on when to use -32800: fork issue #41. Full suite: 589 tests in 43 suites passed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Hi @jstar0, thank you for this contribution. We're consolidating overlapping PRs. #298 includes the same per-exchange isolation as this PR (fixing #254), plus the cancellation fixes for #255, so we'd like to land them together in one change. Thanks for the independent verification here. We plan to close this PR once #298 is merged, so the fix isn't lost in between. If you think something here isn't covered by #298, please comment there or here and we'll make sure it's carried over. |
|
Hi @jstar0, thank you for this PR, and for the care you put into isolating exchanges! We have just opened the Swift SDK 1.0.0 release (#372, branch Could you check whether 1.0.0 covers your case? If it does, we would suggest closing this PR. If something is still missing, please open a new PR against Thank you again for contributing. We would love to see more from you on the new stack! |
Summary
Fixes #254.
StatelessHTTPServerTransportcurrently keys response waiters by the client'sraw JSON-RPC id. Because ids are scoped to each client, concurrent POSTs can
legally reuse the same id; the later request then overwrites the earlier
continuation, leaving one HTTP exchange suspended indefinitely. String and
integer ids also collide after stringification.
Changes
This change assigns a private UUID to each in-flight HTTP exchange before the
request is yielded to
Server. Responses route by that private id, then restorethe client's original string or integer id before returning over HTTP.
The same exchange identity now scopes HTTP request context, while typed raw-id
aliases preserve existing direct lookups. A package-only mapping keeps
Server.currentHandlerContext.idand cancellation lookup on the original clientid without changing public transport or handler APIs. Cancellation fails closed
when multiple active exchanges make a reused wire id ambiguous.
Verification
flight before sending either response.
cancellation compatibility coverage.
swift test -vResult: 555 tests in 40 suites passed.
Scope
are unchanged.
completion. PR fix: StatelessHTTPServerTransport leaves the original POST hanging after notifications/cancelled (#255) #260 covers that separate path and currently lists StatelessHTTPServerTransport: concurrent requests sharing a JSON-RPC id overwrite each other's response waiter (hang + continuation leak) #254 as a
non-goal; if it lands first, its raw-id waiter lookup will need to resolve the
active exchange instead.