Skip to content

fix(mcp): fix Windows MCP spawn double-quoting that breaks all MCP servers#133

Open
dengmik-commits wants to merge 6 commits into
lessweb:mainfrom
dengmik-commits:dev
Open

fix(mcp): fix Windows MCP spawn double-quoting that breaks all MCP servers#133
dengmik-commits wants to merge 6 commits into
lessweb:mainfrom
dengmik-commits:dev

Conversation

@dengmik-commits
Copy link
Copy Markdown
Contributor

Summary

The quoteWindowsShellArg function in createMcpSpawnSpec wrapped every argument in double quotes unconditionally, producing command strings like "npx" "-y" "@playwright/mcp".

When passed to spawn() with shell: true, Node.js wraps the entire string again for cmd.exe, causing double-quoting that breaks command parsing. All MCP servers (playwright, fetch, memory, github) failed to start on Windows.

Fix

Only quote arguments that actually contain spaces or double-quotes. Simple args like npx, -y, @playwright/mcp are joined as-is (e.g., npx -y @playwright/mcp), which prevents double-wrapping by Node.js's shell handling.

Changes

  • src/mcp/mcp-client.ts: replace quoteWindowsShellArg (unconditional quoting) with quoteWindowsArgIfNeeded (conditional quoting)
  • src/tests/mcp-client.test.ts: update test to match new behavior

…rvers

The quoteWindowsShellArg function wrapped every argument in double quotes unconditionally, producing command strings like '"npx" "-y" "@playwright/mcp"'. When passed to spawn() with shell:true, Node.js wraps the entire string again for cmd.exe, causing double-quoting that breaks command parsing. All MCP servers (playwright, fetch, memory, github) failed to start on Windows. Fix: only quote arguments that contain spaces or double-quotes, leaving simple args unquoted.
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.

1 participant