Open
Description
Describe the bug
When connecting to a sdio MCP server on Windows, a warning is printed during the final cleanup. This does not crash the program but indicates that there might be a need for a more graceful shutdown of subprocess transports.
To Reproduce
Run the following script:
import asyncio
from mcp import ClientSession, StdioServerParameters, stdio_client
async def main():
server_params = StdioServerParameters(
command="npx", args=["-y", "@playwright/mcp@latest"]
) # Or any other server
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
print(await session.list_tools())
await asyncio.sleep(2.0)
if __name__ == "__main__":
asyncio.run(main())
Running the above, we get a bunch of warnings and error messages at the end:
Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x...>
Traceback (most recent call last):
...
ValueError: I/O operation on closed pipe
Expected behavior
No warnings or errors should be printed during final cleanup. All subprocess transports and associated resources should be closed cleanly without attempting operations on closed pipes.
Desktop:
- OS: Windows 10
- Version: Python 3.11 (mcp v1.6.0)
Metadata
Metadata
Assignees
Labels
No labels