fix(streamable-http): downgrade stateless 'Terminating session: None' log#2668
Open
adityasingh2400 wants to merge 1 commit into
Open
Conversation
… log
In stateless mode every request created a transport with mcp_session_id=None
and terminated it on completion, producing
'INFO: Terminating session: None' on every request. The repeated noise made
real session terminations hard to find and confused users into thinking
their connection was dropping.
Branch on mcp_session_id in terminate(): keep the existing INFO log for
stateful session terminations, and switch the stateless path to a DEBUG
log with a clearer message ("Stateless request completed, cleaning up
transport"). Adds two caplog tests covering both branches.
Closes modelcontextprotocol#2329.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2329.
In stateless mode, every request logged
INFO: Terminating session: Nonebecause the transport had no session id to print. The repeated noise made real terminations hard to find and confused users into thinking their connection was failing. The cleanup itself is correct and unchanged, only the log line changes.This PR branches on
mcp_session_idinStreamableHTTPServerTransport.terminate():INFOlog with the session id.DEBUG: Stateless request completed, cleaning up transport, which is more accurate (the request is done, not a session being torn down) and lower volume.Two caplog tests are added to
tests/shared/test_streamable_http.pyto cover both branches and prevent regression.This replaces the prior community PR #2357 by @BlocksecPHD, which proposed the same approach and was reviewed positively by another community member but has had no activity since April. Happy to defer or close in favor of #2357 if a maintainer would prefer to revive that branch, the credit belongs there.