Skip to content

Commit d6f1264

Browse files
Fix FallbackProcess cleanup to not terminate process
- Remove process termination from FallbackProcess.__aexit__ - Only handle stream cleanup in __aexit__, not process termination - Process termination is now handled by stdio_client's cleanup sequence This separation of concerns ensures proper MCP spec-compliant shutdown flow where the stdio_client controls the termination sequence, not the process wrapper's context manager. Reported-by: Felix Weinberger 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8ed79fe commit d6f1264

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/mcp/client/stdio/win32.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ async def __aexit__(
7373
exc_val: BaseException | None,
7474
exc_tb: object | None,
7575
) -> None:
76-
"""Terminate and wait on process exit inside a thread."""
77-
self.popen.terminate()
78-
await to_thread.run_sync(self.popen.wait)
76+
"""Clean up streams without terminating the process.
7977
78+
The process termination is handled by stdio_client's cleanup sequence
79+
which implements the MCP spec-compliant shutdown flow.
80+
"""
8081
# Close the file handles to prevent ResourceWarning
8182
if self.stdin:
8283
await self.stdin.aclose()

0 commit comments

Comments
 (0)