Skip to content

fix(streamable-http): downgrade stateless 'Terminating session: None' log#2668

Open
adityasingh2400 wants to merge 1 commit into
modelcontextprotocol:mainfrom
adityasingh2400:adityasingh2400/stateless-log-clarity
Open

fix(streamable-http): downgrade stateless 'Terminating session: None' log#2668
adityasingh2400 wants to merge 1 commit into
modelcontextprotocol:mainfrom
adityasingh2400:adityasingh2400/stateless-log-clarity

Conversation

@adityasingh2400
Copy link
Copy Markdown

Closes #2329.

In stateless mode, every request logged INFO: Terminating session: None because 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_id in StreamableHTTPServerTransport.terminate():

  • Stateful path keeps the existing INFO log with the session id.
  • Stateless path logs 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.py to 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.

… 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.
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.

Improve log clarity for "Terminating session: None" in stateless mode

1 participant