Managing sessions across multiple SSE MCP servers #256
-
Hi, MCP developers! How do you manage client sessions across multiple MCP server instances? We need to be sure that the |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
At the moment, we are using session affinity (aka sticky sessions) for this -- which seems to be working. I did take an initial stab at making an abstraction for better horizontal scaling wihtout session affinity in #186 but I haven't had a chance to circle back to that PR in a little bit 😩 (and not sure when I will -- given that session affinity is working for us atm). |
Beta Was this translation helpful? Give feedback.
-
@robert-jackson-glean Thanks! Is it affinity by IP, cookies, or something else? |
Beta Was this translation helpful? Give feedback.
-
@dronnix - Ya, you definitely can not use cookie based affinity (the cookies aren't shared across requests from the various clients). Using IP based works well for the most part (it does still have issues when many clients are behind a single NAT or when NAT'ed behind multiple public IPs), but I do think I'll need to actually update and finish off #186 to make it the most stable. |
Beta Was this translation helpful? Give feedback.
-
Hi thanks for the info @robert-jackson-glean, we are looking into building a remote server at GitHub. For full resilience across multiple datacenters, we are having to look at using:
We are expecting to have to fork mcp-go to enable experimenting with that, and I'm curious if it will be something you want to merge upstream or not. One thing that I have been mulling over, is that the session management and session tools probably took the wrong track and (as is proposed in Google's Go SDK, I am beginning to feel that composition is a nicer approach. That would mean for stateless use-cases people can use the same server instance, but where servers present different tools to different users, it would mean creating a new instance per request. Sessions would also need to be managed by the implementer, not The quote from the Go SDK:
I hope eventually running off a single connection without session affinity (via websockets or something) can replace this, but in the short term we have very limited options given global scale 😅 Do you have any thoughts on this, especially how we could best achieve this with |
Beta Was this translation helpful? Give feedback.
At the moment, we are using session affinity (aka sticky sessions) for this -- which seems to be working. I did take an initial stab at making an abstraction for better horizontal scaling wihtout session affinity in #186 but I haven't had a chance to circle back to that PR in a little bit 😩 (and not sure when I will -- given that session affinity is working for us atm).