Skip to content

Commit e33dfc4

Browse files
committed
fix(mcpserver): catch KeyboardInterrupt and SystemExit gracefully on stdio transport
Fixes #3551
1 parent 6affe5c commit e33dfc4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/mcp/server/mcpserver/server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,10 @@ def run(
414414

415415
match transport:
416416
case "stdio":
417-
anyio.run(self.run_stdio_async)
417+
try:
418+
anyio.run(self.run_stdio_async)
419+
except (KeyboardInterrupt, SystemExit):
420+
pass
418421
case "sse": # pragma: no cover
419422
anyio.run(lambda: self.run_sse_async(**kwargs))
420423
case "streamable-http": # pragma: no cover

0 commit comments

Comments
 (0)