Skip to content

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

Open
dengmik-commits wants to merge 1 commit into
lessweb:mainfrom
dengmik-commits:main
Open

fix(mcp): fix Windows MCP spawn double-quoting that breaks all MCP servers#164
dengmik-commits wants to merge 1 commit into
lessweb:mainfrom
dengmik-commits:main

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

Replace quoteWindowsShellArg (unconditional quoting) with quoteWindowsArgIfNeeded (conditional quoting). Only arguments that contain spaces or double-quotes are wrapped; simple args like npx, -y, @playwright/mcp are joined as-is (e.g., npx -y @playwright/mcp), preventing double-wrapping by Node.js's shell handling.

Changes

  • src/mcp/mcp-client.ts: replace quoteWindowsShellArg with quoteWindowsArgIfNeeded
  • src/tests/mcp-client.test.ts: update test to match the 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