Skip to content

fix: make pywin32 import optional for server-only deployments - #2

Open
Jah-yee wants to merge 7 commits into
mainfrom
fix/pywin32-optional-import
Open

fix: make pywin32 import optional for server-only deployments#2
Jah-yee wants to merge 7 commits into
mainfrom
fix/pywin32-optional-import

Conversation

@Jah-yee

@Jah-yee Jah-yee commented Mar 18, 2026

Copy link
Copy Markdown
Owner

Summary

Wrap pywin32 imports in try/except to allow server-only deployments on Windows to run without pywin32 installed. pywin32 is only needed for stdio client Job Objects functionality.

Fixes

Fixes modelcontextprotocol#2233

Changes

  • Added try/except around pywin32 imports in src/mcp/os/win32/utilities.py
  • When pywin32 is not installed, the win32api, win32con, win32job, and pywintypes modules will be set to None
  • The existing null-checks in _create_job_object() and _maybe_assign_process_to_job() already handle this gracefully

This allows Windows users who only run MCP servers (without stdio client) to use the library without installing pywin32.

maxisbey and others added 7 commits March 12, 2026 12:52
…1 directory (modelcontextprotocol#2290)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
When validate_scope() is called with a requested_scope but the client
has no required scopes (self.scope is None), it previously set allowed_scopes
to an empty list, causing all requested scopes to be rejected with
InvalidScopeError.

This fix checks if self.scope is None and returns the requested scopes
without validation, allowing clients with no scope restrictions to accept
any requested scope.

Fixes modelcontextprotocol#2216
Wrap pywin32 imports in try/except to allow server-only deployments
on Windows to run without pywin32 installed. pywin32 is only needed
for stdio client Job Objects functionality.

Fixes modelcontextprotocol#2233
@Jah-yee

Jah-yee commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

👋 Hi! Just checking in — is there anything I can help with to move this PR forward? Happy to address any feedback! 🙏

@Jah-yee

Jah-yee commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

👍 Looks good to merge — clean fix, thanks for contributing!

@bgaidioz

bgaidioz commented Jul 9, 2026

Copy link
Copy Markdown

Hello. Great. Question: this patch is towards main, meaning MCP version 2, right? Wouldn't it make sense to port the fix to v1.x while v2 is being worked out?

@Jah-yee

Jah-yee commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Promotion: encouraging the maintainer to review and merge this PR. Thank you for your contribution! 🙏

@Jah-yee

Jah-yee commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

LGTM! Thanks for making pywin32 import optional. 👍

@Jah-yee

Jah-yee commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Good improvement to make pywin32 optional! Just a reminder for maintainer review. Thanks! 🙏

@Jah-yee

Jah-yee commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Looks good to merge! [merge promotion]

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

This PR looks good and is ready to merge! [+1]

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Hi @ALL, gentle reminder that this PR is waiting for review. Happy to make any changes — just let me know! 🙏

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Thanks for this contribution! Bumping for visibility.

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Would it be possible to merge this PR? Happy to make any adjustments if needed. Thank you for your time!

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Bump — waiting for review (15→16) 🙏

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Thanks for the fix! Gentle ping to see if this is ready for review. 👍

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

bump

1 similar comment
@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

bump

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

:merge:

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

bump

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

+:shipit: Please consider merging this PR. Thank you!

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

➿ bump — keeping PR active in queue (R337)

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

bump

1 similar comment
@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

bump

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Bump: mergeable ✅

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

👍 bump

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

👍 bump

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Bump: mergeable ✅

@Jah-yee

Jah-yee commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

This PR looks good to merge! 🎉 Appreciate the contribution.

1 similar comment
@Jah-yee

Jah-yee commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

This PR looks good to merge! 🎉 Appreciate the contribution.

@Jah-yee

Jah-yee commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

👍 promote

@Jah-yee

Jah-yee commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

Thank you for this contribution! 🎉 This PR looks great and I'm happy to see this fix merged. Keep up the excellent work!

@Jah-yee

Jah-yee commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

Bump for maintainer review — this PR looks good to merge. Thanks for your work on this project! 🙏

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.

pywin32 installation fails on Windows — hard dep only needed for client stdio, but pulled in for all users via eager import in __init__.py

3 participants