Repository navigation
Conversation
All http-stream sessions shared one SDK Server, so JSON-RPC ids from different clients collided. When two clients had a request with the same id in flight, the first response was delivered to both of them. Use a per-session SDK Server, the same way the SSE transport already does.
…s client With per-session servers, clients initialize and answer on their own session's server, so a roots/list sent through the shared server waits for the full request timeout. Add an MCPServer-level test for both cases.
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.
@QuantGeekDev all http-stream sessions share one SDK server, so request ids from different clients collide. Clients number requests from 0, so when two clients have a request with the same id in flight, one client's response can be delivered to the other.
This gives each session its own SDK server, same as the SSE transport already does. It also makes
MCPServer.listRoots()return right away for http-stream instead of waiting out the 60s request timeout, since clients now answer on their own session's server.Tested with two clients calling a tool at the same time in both
streamandbatchmodes. On main the second client gets the first client's result; with this change each gets its own. Tests are intests/transports/http/server-session-isolation.test.tsandtests/core/http-stream-session-isolation.test.ts, and the full suite passes.Follow-ups I'd like to do separately: tool instances are shared, so
injectServer()and the progress token can be swapped between overlapping calls (SSE has this too), andsessionTimeout/maxConcurrentSessionsaren't enforced yet.