fix: lazy import mcp module to prevent Windows DLL error on startup#490
Open
BillionClaw wants to merge 1 commit intomistralai:mainfrom
Open
fix: lazy import mcp module to prevent Windows DLL error on startup#490BillionClaw wants to merge 1 commit intomistralai:mainfrom
BillionClaw wants to merge 1 commit intomistralai:mainfrom
Conversation
Move mcp imports from module-level to inside functions that use them. This prevents the ImportError: DLL load failed while importing _win32sysloader error on Windows 10 during startup, which occurred because the mcp package transitively imports pywin32 on Windows. With lazy imports, Windows users can start vibe without MCP servers configured. The pywin32 error will only occur if they actually try to use MCP functionality. Fixes mistralai#479
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows 10, installing and running "mistral-vibe" fails immediately with:
This prevents Windows users from using the CLI at all, even when they don't intend to use MCP functionality.
Root Cause
The "mcp" package transitively imports "pywin32" on Windows via:
Since "vibe/core/tools/mcp/tools.py" imported MCP modules at the top level, the pywin32 DLL loading error occurred during startup for all Windows users, regardless of whether they actually use MCP servers.
Change
Move MCP imports from module-level to inside the functions that use them:
This ensures the pywin32 DLL is only loaded when MCP functionality is actually invoked, not during CLI startup.
Verification
Risk/Edge Cases
Fixes #479