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.
Enabling distributed MCP server
Motivation and Context
The current implementation of streamableHttps relies on a single node managing all requests or using sticky sessions on a loadbalancer to ensure the same user always hits the same machine. This particular setup faces some problems if the sticky node becomes unavailable for some reason.
This approach makes minimal changes to make fully distributed setup relatively easy.
For a distributed mode you will have to create new transport for any inbound connection. Prior to initializing the transport you need to validate mcp-session-id against a db of open session (or just ignore if undefined = new session).
Initialize transport with optional sessionId argument (if defined, the transport will assume session has already been initialized). Additionally define disableLocalSse: true.
Listen to responseSse events from transport and publish them to a global pub/sub
Listen to the global pub/sub for events matching the current sessionId and emit them as sse locally.
A pseudo example would be something like:
How Has This Been Tested?
Tested locally - this PR is a draft, if approach makes sense we should add some tests
Breaking Changes
None
Types of changes
Checklist
Additional context