Skip to content

Fix Windows subprocess NotImplementedError (STDIO clients) #596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

theailanguage
Copy link

Fix subprocess creation errors on Windows for STDIO client connections.
This updates create_windows_process to properly handle the case where asyncio cannot create subprocess transports on Windows by falling back to using the subprocess module manually.

Additionally, minor import sorting and style issues have been fixed according to ruff linter checks.


Motivation and Context

On Windows systems, MCP clients that connect via STDIO were failing with a NotImplementedError during anyio.open_process(). This is because asyncio on Windows does not implement full support for subprocess transports.

This change provides a clean workaround:

  • Attempt async process creation first.
  • If not supported, fall back to classic subprocess.Popen with asyncio wrapping.

This allows MCP STDIO clients (e.g., streamlit_client_ui.py) to work successfully on Windows without changing user workflows.


How Has This Been Tested?

  • Tested manually on Windows 11, Python 3.13.
  • Ran streamlit_client_ui.py to launch the MCP client.
  • Successfully connected to STDIO MCP servers without errors.
  • Validated tool loading and interaction without subprocess creation issues.
  • Verified no new ruff or pyright issues for the updated file.

Breaking Changes

No breaking changes.

  • The fallback mechanism is backward compatible.
  • Linux/macOS users are unaffected.
  • Windows users gain compatibility without needing to change their code.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update (style improvements, minor doc updates)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This fix is especially important for making MCP tools and agents accessible on all platforms, including Windows, thereby helping broader adoption.

@theailanguage
Copy link
Author

Hi team!

This is my first pull request. PR fixes Windows compatibility for MCP STDIO clients by introducing a fallback to subprocess.Popen wrapped with async I/O streams. It ensures that Windows users can now use streamlit and similar STDIO clients without errors.

Please let me know if you'd like any further changes. Thank you for your time and for maintaining such an awesome project!

Regards
[Kartik / theailanguage]

@theailanguage
Copy link
Author

@dsp-ant @jerome3o-anthropic would appreciate any kind of feedback on this if possible from your end. Thanks a ton!

Regards
[Kartik / theailanguage]

@ihrpr ihrpr added this to the r-05-25 milestone Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants