[Bug]: Windows stdio upstreams fail when the command path contains a space
What happened?
On Windows, a stdio upstream whose command path contains a space never starts. cmd.exe gets the path with literal backslash-escaped quotes around it and rejects it:
'\"C:/Users/<user>/AppData/Local/Programs/HTTP Toolkit/resources/httptoolkit-mcp.cmd\"' is not recognized as an internal or external command,
operable program or batch file.
This affects any program installed under a folder with a space, such as Program Files or HTTP Toolkit.
I think the cause is in WrapWithUserShell (internal/shellwrap/shellwrap.go). On Windows it builds the command string "C:/.../HTTP Toolkit/.../httptoolkit-mcp.cmd" and returns it as a single argument, ["/c", commandString]. When exec.Command turns that into a Windows command line, Go escapes the embedded quotes as \". cmd.exe doesn't treat \" as an escape, so it looks for a program literally named \"C:/...cmd\".
A possible fix is to set cmd.SysProcAttr.CmdLine yourself when the shell is cmd.exe (for example cmd.exe /s /c "<commandString>"), so Go doesn't re-escape the string.
Expected behavior
The server starts the same way it does when the path has no spaces.
Steps to reproduce
- On Windows, add a stdio upstream whose command path contains a space:
mcpproxy upstream add http-toolkit -- "C:\Users\<user>\AppData\Local\Programs\HTTP Toolkit\resources\httptoolkit-mcp.cmd" - Run
mcpproxy upstream logs http-toolkit. - Every connection attempt fails with "server process exited before completing the MCP initialize handshake" and the stderr shown above.
Workaround: use the 8.3 short path, which has no spaces (C:\Users\<user>\AppData\Local\Programs\HTTPTO~1\RESOUR~1\httptoolkit-mcp.cmd). With that path the same server connects and initializes normally.
MCPProxy version
MCPProxy v0.74.0 (personal) windows/amd64
Operating system
Windows
Relevant logs
INFO | managed/client.go:638 | Starting connection attempt | {"server": "http-toolkit", "transport": "stdio", "command": "C:/Users/<user>/AppData/Local/Programs/HTTP Toolkit/resources/httptoolkit-mcp.cmd", "protocol": "stdio"}
INFO | core/monitoring.go:57 | stderr | {"server": "http-toolkit", "message": "'\\\"C:/Users/<user>/AppData/Local/Programs/HTTP Toolkit/resources/httptoolkit-mcp.cmd\\\"' is not recognized as an internal or external command,"}
ERROR | core/connection_stdio.go:299 | MCP initialize JSON-RPC call failed | {"server": "http-toolkit", "error": "transport error: transport closed"}
ERROR | core/connection.go:353 | Connection failed | {"server": "http-toolkit", "transport": "stdio", "error": "stdio transport (command=\"C:\\\\Windows\\\\system32\\\\cmd.exe\", docker_isolation=false): server process exited before completing the MCP initialize handshake"}
Pre-submission checklist
- [x] I searched existing issues and did not find a duplicate
- [ ] I ran
mcpproxy doctorand reviewed the output