Skip to content

MCP Server can not support cluster #201

Closed as not planned
Closed as not planned

Description

@yu199195

Hi the this code :

        if (this.isClosing) {
            return ServerResponse.status(HttpStatus.SERVICE_UNAVAILABLE)
                    .body("Server is shutting down");
        }

        if (request.param("sessionId").isEmpty()) {
            return ServerResponse.badRequest()
                    .body(new McpError("Session ID missing in message endpoint"));
        }

        String sessionId = request.param("sessionId").get();
        McpServerSession session = sessions.get(sessionId);

        if (session == null) {
            return ServerResponse.status(HttpStatus.NOT_FOUND)
                    .body(new McpError("Session not found: " + sessionId));
        }

when mcp server is cluster model. McpServerSession session = sessions.get(sessionId); is null

Activity

  1. hongling-dev commented on Apr 28, 2025

    @hongling-dev

    When deploying in a cluster, I connect through the domain name. Since SSE is a long-lived, stateful protocol, the intermediate network proxy layer (such as Nginx) is configured with routing rules to ensure that the same client request is routed to the same MCP server, for example, IP Hash.

  2. hongling-dev commented on Apr 28, 2025

    @hongling-dev

    'Streamable HTTP Transport' can solve or alleviate this problem

  3. yu199195 commented on Apr 29, 2025

    @yu199195
    Author

    @lambochen thanks~

  4. chensi2017 commented on Apr 29, 2025

    @chensi2017

    java什么时候才能支持streamable http呢

  5. lvchengwei0901 commented on May 9, 2025

    @lvchengwei0901

    这个当前有解决方案吗?

  6. chemicL commented on Feb 17, 2026

    @chemicL
    Member

    On one hand, this issue will not be solved for the legacy SSE transport type due to its' design. We can address the problem for Streamable HTTP in two ways:

    • use the Stateless transport variants (losing the bi-directional nature)
    • implement a persistent session storage

    There is a drawback with the current Streamable HTTP specification though, which assumes the client first initializes with the server. In case of multiple replicas of the server, the replicas that have not seen the client might just fail, that's implementation specific, not addressed by the MCP Specification. There is a current effort to implement a Stateless-by-default Streamable HTTP specification, which would help resolve this.

    I intend to keep the issue open as implementing the session storage will be crucial for the upcoming spec changes and we could perhaps relax the initialization requirement to make scalability with sessions possible.

  7. Kehrlann commented on Sep 4, 2026

    @Kehrlann
    Contributor

    Sessions are not supported in the new 2026-07-28 spec. We won't implement session storage for the older versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions