Skip to content

Create one server per transport to avoid message-leaking #47

@jonathansampson

Description

@jonathansampson

Create a distinct McpServer/Server instance per transport to avoid unintended backflow of data to the wrong client (see modelcontextprotocol/typescript-sdk#820). While the scenario of mapping request➡️response to the proper client is patched in recent versions of the SDK, there still remains areas within the Protocol class that communicate exclusively with the last-connected transport (which may not be the proper transport).

To avoid sending notifications and more to the wrong client, create a distinct McpServer/Server instance per transport, and consider using the sendNotification method exposed to tool callbacks. While arguably less efficient than a single 1:n McpServer architecture, the 1:1 approach should guarantee that only the intended recipient is ever contacted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions