modelcontextprotocol / modelcontextprotocol/typescript-sdk

[BUG] Multi-Node Deployment with Persistent Storage Mode not working

Open
#776 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug fix proposed P2 ready for work
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:

  1. Use as base the 'simpleStreamableHttp' example
  2. Change the eventStorage to be persistent (fileDisk, Redis, Memcached, etc.)
  3. Start, locally, 2 instances of the server in different ports
  4. Create, configure and start a NGINX server that make the redirect for those instances
  5. Using MCP Inspector try to connect and use any tool (Greet for example)
  6. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.