We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 616476f commit 686d483Copy full SHA for 686d483
1 file changed
src/mcp/server/streamable_http_manager.py
@@ -133,6 +133,12 @@ async def lifespan(app: Starlette) -> AsyncIterator[None]:
133
yield # Let the application run
134
finally:
135
logger.info("StreamableHTTP session manager shutting down")
136
+ # Gracefully terminate all active sessions before cancelling tasks
137
+ for transport in list(self._server_instances.values()):
138
+ try:
139
+ await transport.terminate()
140
+ except Exception:
141
+ logger.debug("Error terminating transport during shutdown", exc_info=True)
142
# Cancel task group to stop all spawned tasks
143
tg.cancel_scope.cancel()
144
self._task_group = None
0 commit comments