-
Notifications
You must be signed in to change notification settings - Fork 572
Multiple clients to the same SSE connection? #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think maybe the README is just a touch misleading as it includes: app.get("/sse", async (req, res) => {
const transport = new SSEServerTransport("/messages", res);
await server.connect(transport);
}); |
I suspect you want an instance of McpServer per SSE connection |
I struggle with similar issues. |
I've built a factory that takes tools, prompts, resources, etc. and returns new instances of the McpServer for each |
Maybe should keep this issue open until we update the README with this nuance, though? |
As I understood the specification, clients and servers have a 1:1 relationship. Each connecting client requires an instance of
Rather than the Typescript SDK implementing a way to manage client/server mappings, I think the README/docs could instead give a basic example for people to get started. |
Someone in another issue was mentioning implementing a websocket transport. It's theoretically not that complicated and I've seen several examples pop up. But I wonder if there's some underground mines or fundamental issues that the MCP Core team saw that made them chose the SSE approach. They aren't using standard SSE - SSE is meant to be unidirectional. But we are doing bi-directional communication with SSE where we can call tools and get the tool call events in the same SSE connection. Would love to hear some rationale on this, or if anyone has more thoughts |
there was a lengthy back and forth in the GH discussion around stateful/less transports and web sockets came up several times. i'm on mobile and can't link it but it should be easy to find. ultimately it led to the current PR spec draft / RFC. although the focus on this one was primarily to offer a stateless HTTP variant of the spec. it's still not entirely clear to me why this pseudo-bi-directional POST + SSE was chosen either. to the best of my knowledge from the thread it comes down to simplicity and using native HTTP features. of course there are benefits of using HTTP over websockets in certain, arguably most, cases and SSE has some well established uses. but i don't know that it was intended to be used this way specifically when there is an existing protocol that aligns with the desired behavior of bi-directionality. one thing to consider is a core philosophy of MCP is to keep server complexity low and shift responsibility to the client. it's a pragmatic philosophy as it encourages development on the server side which in the long run will always be of higher demand and novelty relative to a smaller pool of clients. from that i can at least appreciate the intention behind the choice since HTTP is simpler and familiar to a broader audience. on the other hand, i believe that well implemented SDKs (and abstractions over them) can reduce the perceived complexity of websockets. and i feel the current POST + SSE approach while feeling simple on the surface, grounded in that HTTP familiarity, in practice leads to some confusing mental models and implementations. i left a comment, that was genuinely well intentioned but i don't think was well received, that this current design is like trying to invent web sockets before web sockets. i think the WS discussion will come up again. this is an important spec update to further encourage server development with the stateless and more traditional use of HTTP. i just hope it doesn't get held up by the language around the now optional POST + SSE streaming portion. |
A couple examples in the readme would go a long way!!! |
That makes SSE connection pushed to newest user if there are more than one user ,because serve only save the newest transport |
👋 Because
server.connect(transport)
replaces any existing transport for a Server, I've been struggling to understand the intended pattern for simultaneous SSE client connections. Is it intended that an SSE MCP server can only have one Client?Example:
One workaround for this is to create a clone of the McpServer within the /sse handler, but that doesn't seem to match with the concept of a "sessionId".
Would appreciate any guidance here, thanks!
The text was updated successfully, but these errors were encountered: