diff --git a/src/mcp/client/stdio.py b/src/mcp/client/stdio.py index df721bbc..9e45d9ed 100644 --- a/src/mcp/client/stdio.py +++ b/src/mcp/client/stdio.py @@ -159,4 +159,7 @@ async def stdin_writer(): ): tg.start_soon(stdout_reader) tg.start_soon(stdin_writer) - yield read_stream, write_stream + try: + yield read_stream, write_stream + finally: + process.terminate()