Skip to content

Commit b5f79b2

Browse files
author
PR-Contributor
committed
fix: improve log clarity for stateless mode session termination
In stateless HTTP mode, every request logs 'INFO: Terminating session: None'. This is correct behavior but confusing to users who assume their connection is failing. Changes: - Downgrade stateless cleanup to DEBUG (routine, not noteworthy) - Use clearer wording: 'Stateless request completed, cleaning up transport' - Keep existing INFO-level log for actual session terminations Fixes #2329
1 parent 92c693b commit b5f79b2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mcp/server/streamable_http.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,10 @@ async def terminate(self) -> None:
767767
"""
768768

769769
self._terminated = True
770-
logger.info(f"Terminating session: {self.mcp_session_id}")
770+
if self.mcp_session_id:
771+
logger.info(f"Terminating session: {self.mcp_session_id}")
772+
else:
773+
logger.debug("Stateless request completed, cleaning up transport")
771774

772775
# We need a copy of the keys to avoid modification during iteration
773776
request_stream_keys = list(self._request_streams.keys())

0 commit comments

Comments
 (0)