modelcontextprotocol / modelcontextprotocol/typescript-sdk
[BUG] Multi-Node Deployment with Persistent Storage Mode not working
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
Description
Describe the bug
I'm need to deploy my MCP Server in a multi-node environment (always has 2 or more server) with StreamableHTTPServerTransport. On the initialization fase everything occurs normally, but, when a request is made to other node of the cluster I'm getting an error because this node doesn't have the client (it interpret that the connection was not initialized).
To Reproduce
Steps to reproduce the behavior:
- Use as base the 'simpleStreamableHttp' example
- Change the
eventStorageto be persistent (fileDisk, Redis, Memcached, etc.) - Start, locally, 2 instances of the server in different ports
- Create, configure and start a NGINX server that make the redirect for those instances
- Using MCP Inspector try to connect and use any tool (Greet for example)
- You will receive an error
Expected behavior
As described in the documentation any node should respond to the client without problems.
Logs
MCP error -32001: Error POSTing to endpoint (HTTP 400): {"jsonrpc":"2.0","error":{"code":-32000,"message":"Bad Request: No valid session ID provided"},"id":null}
Additional context
I've made a workaround for this issue saving the initialize body in one instance and using it for re-initialize in the other instance (without the knowledge of the client) - but it don't seen right.
It could be:
- a problem in the documentation
- a problem in the implementation
- a problem of interpretation of my own
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the simpleStreamableHttp example and the persistent storage mode documentation. Reproduce the issue with two server instances behind NGINX using persistent eventStorage, then trace StreamableHTTPServerTransport session handling when a request reaches the other node. Done means MCP Inspector can connect and use a tool successfully through either node without a missing-session error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nginx, typescript
- Domain
- api, backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100