Skip to content

fix: lazy import mcp module to prevent Windows DLL error on startup#490

Open
BillionClaw wants to merge 1 commit intomistralai:mainfrom
BillionClaw:fix/windows-import-error
Open

fix: lazy import mcp module to prevent Windows DLL error on startup#490
BillionClaw wants to merge 1 commit intomistralai:mainfrom
BillionClaw:fix/windows-import-error

Conversation

@BillionClaw
Copy link
Copy Markdown

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:

  • "list_tools_http()" - imports inside the function
  • "call_tool_http()" - imports inside the function
  • "list_tools_stdio()" - imports inside the function
  • "call_tool_stdio()" - imports inside the function

This ensures the pywin32 DLL is only loaded when MCP functionality is actually invoked, not during CLI startup.

Verification

  • Python syntax check passes: "python3 -m py_compile vibe/core/tools/mcp/tools.py"
  • Git diff whitespace check passes: "git diff --check"
  • Verified 4 lazy import statements are in place via grep
  • The fix allows Windows users to start vibe without MCP servers configured

Risk/Edge Cases

  • Type checking: The module uses "TYPE_CHECKING" guard for type hints, so type checkers still have full visibility
  • Performance: Lazy imports add negligible overhead (only when MCP functions are called)
  • Backwards compatibility: No API changes - all function signatures remain identical

Fixes #479

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
@BillionClaw BillionClaw requested a review from a team as a code owner March 13, 2026 19:26
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.

bug: ImportError when trying to launch on Windows 10

1 participant