Skip to content

fix(streamable-http): reduce stateless termination log noise#2357

Open
BlocksecPHD wants to merge 1 commit intomodelcontextprotocol:mainfrom
BlocksecPHD:fix/stateless-termination-log-2329
Open

fix(streamable-http): reduce stateless termination log noise#2357
BlocksecPHD wants to merge 1 commit intomodelcontextprotocol:mainfrom
BlocksecPHD:fix/stateless-termination-log-2329

Conversation

@BlocksecPHD
Copy link

Summary

This PR adjusts termination logging in StreamableHTTPServerTransport for stateless mode.

  • Keep INFO log for stateful session termination (session id exists)
  • Emit DEBUG log for stateless transport cleanup (mcp_session_id is None)
  • Update wording to reflect normal request completion in stateless mode

This addresses confusion reported in #2329 where users interpret Terminating session: None as an error condition.

Changes

  • src/mcp/server/streamable_http.py
    • Conditional log level/message in terminate()
  • tests/server/test_streamable_http_manager.py
    • Add regression test to assert:
      • debug message exists for stateless cleanup
      • info-style Terminating session: None message is not emitted

Validation

Ran targeted tests locally:

python -m pytest tests/server/test_streamable_http_manager.py \
  -k 'stateless_requests_memory_cleanup or stateless_termination_logs_debug_not_info'

Result: 2 passed

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.

1 participant