fix(mcp): fix Windows MCP spawn double-quoting that breaks all MCP servers#133
Open
dengmik-commits wants to merge 6 commits into
Open
fix(mcp): fix Windows MCP spawn double-quoting that breaks all MCP servers#133dengmik-commits wants to merge 6 commits into
dengmik-commits wants to merge 6 commits into
Conversation
…sx, PromptInput.tsx
…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.
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.
Summary
The
quoteWindowsShellArgfunction increateMcpSpawnSpecwrapped every argument in double quotes unconditionally, producing command strings like"npx" "-y" "@playwright/mcp".When passed to
spawn()withshell: true, Node.js wraps the entire string again forcmd.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/mcpare 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: replacequoteWindowsShellArg(unconditional quoting) withquoteWindowsArgIfNeeded(conditional quoting)src/tests/mcp-client.test.ts: update test to match new behavior