Skip to content
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

Make the server resilient to restart in SSE mode #102

Closed
sebastienblanc opened this issue Feb 9, 2025 · 6 comments · Fixed by #109
Closed

Make the server resilient to restart in SSE mode #102

sebastienblanc opened this issue Feb 9, 2025 · 6 comments · Fixed by #109

Comments

@sebastienblanc
Copy link

Hi !
Not sure if my questions here or on the mcp-client side.
Basically I would like the mcp-server to be resilient to restarts, now of course after a restart, the SSE connection is lost and when a request comes in, I get something like :

2025-02-09 16:46:27,365 ERROR [io.qua.mcp.ser.sse.run.SseMcpMessageHandler] (vert.x-eventloop-thread-1) Connection not found: NmRkZTk4ZDQtNmY3My00NDQ0LWJjOWEtNTBkNTg4MDlmZTQ4

Is there a way to solve to that ? Like force a reconnection if the connection is not found ?

@sebastienblanc
Copy link
Author

Maybe we could have https://github.com/quarkiverse/quarkus-mcp-server/blob/main/core/runtime/src/main/java/io/quarkiverse/mcp/server/runtime/ConnectionManager.java as an interface, so we could have a implementation that uses Redis for instance, to keep the connection details ?

@mkouba
Copy link
Contributor

mkouba commented Feb 10, 2025

Hi Sebastien, that is a very good question. However, I'm not so sure there's something we can do on the server side. If an SSE connection is lost then the server has no way to send messages to the client and reconnection (and MCP reinitialization) is probably the only way to fix that.

Maybe we could have https://github.com/quarkiverse/quarkus-mcp-server/blob/main/core/runtime/src/main/java/io/quarkiverse/mcp/server/runtime/ConnectionManager.java as an interface, so we could have a implementation that uses Redis for instance, to keep the connection details ?

This would help to keep the session state but the SSE connection is lost anyway.

WDYT @jmartisk

@sebastienblanc
Copy link
Author

Make sense. If I'm using quarkus-langchain4j-mcp on the client side, is there a way to catch the 400 response and initiate a new connection ?

@mkouba
Copy link
Contributor

mkouba commented Feb 10, 2025

Make sense. If I'm using quarkus-langchain4j-mcp on the client side, is there a way to catch the 400 response and initiate a new connection ?

I have no idea, that's a question for Jan ;-).

@jmartisk
Copy link

jmartisk commented Feb 17, 2025

Yeah, it's on my radar to see what we can do on the client side, thanks for opening the issue there. I assume it could try reconnecting automatically and just doing the whole init phase again, failing the currently active operations.
I assume this server-side issue can be closed now?

@mkouba
Copy link
Contributor

mkouba commented Feb 17, 2025

I assume this server-side issue can be closed now?

Yes, I think so. FYI I've implemented the dummy initialization in the dev mode for SSE which basically means that the server is able to accept new requests after the hot reload if the client reconnects SSE.

@mkouba mkouba closed this as completed Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants