Skip to content

Conversation

jirispilka
Copy link
Contributor

@jirispilka jirispilka commented Oct 10, 2025

MCP connections don't properly close when clients disconnect, keeping containers alive indefinitely.
Implemented automatic session cleanup using internal DELETE requests after 60s timeout (in const.py).
This timeout should match idle timeout of the Actor standby settings as this variable is not exposed. Yes, it is a bit inconvenient.

I'll propagate these changes to other templates after this is reviewed.

Test run (created multi-sessions) with list/tool

…eping containers alive indefinitely.

Implemented automatic session cleanup using internal DELETE requests after 300s timeout (in const.py).

This template would deserve a bit more refactoring but since I'll need to propagate it to existing servers I kept the changes to server.py and mcp_gateway.py minimal (except the actor start :(, I've removed it but it has made this PR slightly bigger)
@jirispilka jirispilka requested a review from JJetmar October 10, 2025 07:34
Copy link
Contributor

@JJetmar JJetmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, there is an implicit functionality of the python mcp package causing the "sessions" to to be still alive by actively polling their status (or something) via HTTP requests, and that is what keeps our stand-by Actors running forever.

This looks like an effective fix.

@jirispilka
Copy link
Contributor Author

As I understand it, there is an implicit functionality of the python mcp package causing the "sessions" to to be still alive by actively polling their status (or something) via HTTP requests, and that is what keeps our stand-by Actors running forever.

This looks like an effective fix.

I still don’t fully understand the underlying issue.
I tried different settings for the MCP server — json_response (so the server works in request → response mode), stateless config, and keep_alive = 1 — but none of them worked.

After spending some time on it, I decided to patch it temporarily by killing sessions internally and will figure out a proper solution later.

@jirispilka jirispilka merged commit 4df4e01 into main Oct 10, 2025
2 checks passed
@jirispilka jirispilka deleted the fix/weather-session branch October 10, 2025 11:52
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 this pull request may close these issues.

2 participants