-
Notifications
You must be signed in to change notification settings - Fork 323
feat: route to MCPAgent by agentName #257
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
Conversation
|
|
I suspect you're running into this issue where you have multiple clients on the same session: #172 The issue is that one DO instance is intended to manage a single session+transport IIRC. But as you mentioned, maybe that's not spec-compliant, but not certain
FWIW I've done this by having a DO sidecar to handle state per user (see: https://github.com/cloudflare/mcp-server-cloudflare/blob/main/apps/sandbox-container/server/containerMcp.ts), but it seems like it might be useful to have the option to route sessions to certain DOs |
Hey, thanks for your reply and link. It's a nice idea and would probably work quite well for me. Would you propose I do that? or would you be happy to add the idea behind this PR? |
f0fb470 to
12225f1
Compare
0ebb6ca to
de2ae3c
Compare
|
Ran into this same issue to just given how DO works. Another thing we could do is expose an option like A hacky way I've been doing is overriding the session ID used for the MCP session to be the user ID of users EDIT: Thinking about it more, overriding the session ID isn't sound since it might affect how the MCP server handles responses. Actually that container MCP code is amazing 👀 it actually makes more sense / cleaner to use a separate DO for each user versus forcing the |
|
Hey, I wanted similar feature (i.e route every user back to the same MCP they created). I don't think the current solution in the PR is the best way to go, instead I think serveSSE/serve should provide a way to run something like preFetch function to determine how the routing happens or even just allow multiple users to use the same sessionId. This will be a more general solution. I managed to do somerthing like this by wrapping serveSSE but there is a limitation of only one websocket connection in the MCPAgent code, I was able to remove that limitation locally and the following code worked. This way we can support not just a single named server but arbitrary policies like one MCP server per user or a group sharing MCP servers based on definition from the app database. Is this something on the horizon or should I contribute? The only change I made in the MCPAgent code is removing the one websocket connection limit. |
|
Closing this as it seems like it would add too much complexity and goes against how MCP is shaping up on a protocol level. I am using the sidecar DO method described above by @cmsparks |
Use-case is to make a persistent server for a whole team to use. This server should maintain state across multiple interactions. Hence the routing needs to work explicitly.
I can't seem to make sse work. There is an arbitrary limit on the number of clients connected to a single server of 1 which doesnt seem to be present in the MCP spec. This confused me and would love some guidance from those who understand it better.