Skip to content

Commit a804442

Browse files
committed
only remove error sessions and not those that have not been terminated
1 parent 694cabc commit a804442

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/mcp/server/streamable_http_manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,18 @@ async def run_server(
250250
exc_info=True,
251251
)
252252
finally:
253-
# Cleanup logic
253+
# Only remove from instances if not terminated
254254
if (
255255
http_transport.mcp_session_id
256256
and http_transport.mcp_session_id
257257
in self._server_instances
258+
and not (
259+
hasattr(http_transport, "_terminated")
260+
and http_transport._terminated
261+
)
258262
):
259263
logger.info(
260-
"Cleaning up crashed/terminated session "
264+
"Cleaning up crashed session "
261265
f"{http_transport.mcp_session_id} from "
262266
"active instances."
263267
)

0 commit comments

Comments
 (0)