Fix Windows subprocess NotImplementedError (STDIO clients) by theailanguage · Pull Request #596 · modelcontextprotocol/python-sdk
ihrpr previously requested changes May 28, 2025
felixweinberger added a commit that referenced this pull request
Jun 23, 2025On Windows, asyncio.create_subprocess_exec raises NotImplementedError due to incomplete subprocess transport support in ProactorEventLoop. This commit implements a fallback using subprocess.Popen directly with async wrappers. The fix introduces a DummyProcess class that wraps subprocess.Popen and provides async-compatible stdin/stdout streams using anyio's FileReadStream and FileWriteStream. This allows MCP STDIO clients to work on Windows without encountering the NotImplementedError. Based on PR #596 by @theailanguage Github-Issue: #596 Reported-by: theailanguage
…est_stdio_client on windows due to tee command issues" This reverts commit fef614d8cfc2b48ffa302f54257ec8d09ab26fbf.
…ng a bad inline script. This ensures the subprocess fails to launch, which better matches the test's intent.
felixweinberger added a commit that referenced this pull request
Jul 4, 2025This restores the pre-#596 behavior where anyio.open_process is tried first, falling back to subprocess.Popen only when necessary (e.g., when using SelectorEventLoop on Windows). The approach: 1. Try anyio.open_process with CREATE_NO_WINDOW flag 2. If NotImplementedError, fall back to subprocess.Popen wrapper 3. If other exception, retry anyio.open_process without flags Also refactored to extract the fallback logic into a separate _create_windows_fallback_process function for better code organization.
felixweinberger added a commit that referenced this pull request
Jul 4, 2025This re-establishes behavior before #596 in the default case. - Attempt to use anyio's native open_process function on Windows - Fall back to subprocess.Popen only if NotImplementedError is raised - This improves compatibility with event loops that support async subprocesses - Extract fallback logic into separate function for clarity
felixweinberger added a commit that referenced this pull request
Jul 7, 2025This re-establishes behavior before #596 in the default case. - Attempt to use anyio's native open_process function on Windows - Fall back to subprocess.Popen only if NotImplementedError is raised - This improves compatibility with event loops that support async subprocesses - Extract fallback logic into separate function for clarity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters