Close server session after handle stateless request by hopeful0 · Pull Request #1116 · modelcontextprotocol/python-sdk

@hopeful0

@hopeful0 mentioned this pull request

Jul 10, 2025

felixweinberger

@hopeful0

felixweinberger

@hopeful0 hopeful0 deleted the stateless-server-session-close branch

July 14, 2025 16:34

felixweinberger added a commit that referenced this pull request

Jul 14, 2025
This test verifies that PR #1116's fix properly cleans up transport
resources for stateless requests. The test mocks StreamableHTTPServerTransport
to track when _terminate_session() is called and ensures it's invoked for
each stateless request to prevent memory leaks.

Without the fix (commenting out the _terminate_session() call), this test
fails, confirming it properly detects the memory leak issue.

Github-Issue:#1116

Kludex