Repository navigation
fix(windows): spawn npm/uv shims (npx.cmd) for stdio backends - #123
Merged
Merged
Conversation
On Windows `CreateProcess` only appends `.exe` to a bare program name, so a backend configured as `"command": "npx"` (or any npm-installed CLI, which is a `.cmd` shim) failed with "program not found" even though `resolve_command` had just found it via PATHEXT. Most published MCP servers are started through `npx`, so the proxy could not run them on Windows. Add `which::program_for_spawn`: for a bare, extensionless name on Windows, resolve it through PATH + PATHEXT and hand the full path to `Command::new` (std runs `.cmd`/`.bat` through cmd.exe with its escaping). A PATHEXT match wins over an extensionless file in the same directory, because nodejs ships a POSIX `npx` script next to `npx.cmd`. Used at all three spawn sites (stdio transport, CLI transport, CLI discovery). No change on unix. Tests: program_for_spawn keeps explicit paths/extensions; on Windows it picks `shim.cmd` over a bare `shim` script. Also carries the two `cfg(unix)` test gates from the Windows build fix so this branch tests standalone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
avelino
approved these changes
Nov 9, 2026
Owner
There was a problem hiding this comment.
Thanks, @ozkanerbatuhan, this one is clean. Resolving the bare name through PATH + PATHEXT only at spawn time, letting std run .cmd through cmd.exe with its own quoting, and preferring npx.cmd over the POSIX npx that nodejs ships next to it is exactly how I'd want it. Unix stays a no-op, and the live check with npx, uvx and native exes is appreciated.
I read the full diff and merged it locally on top of current main (together with #125): cargo test --all-targets passes, 1138 tests.
The red advisories job on this PR is from Oct 17 and isn't about your change, main has moved since. Could you rebase on main so CI gets a fresh run? I'll merge as soon as it's green.
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.
Part of #121 (item 2).
CreateProcessonly appends.exeto a bare name, so"command": "npx"failed withprogram not foundalthoughresolve_commandhad foundnpx.cmd. Newwhich::program_for_spawnresolves a bare, extensionless name through PATH + PATHEXT and passes the full path toCommand::new(std runs.cmd/.batvia cmd.exe with its escaping). PATHEXT matches win over an extensionless file in the same dir (nodejs ships a POSIXnpxnext tonpx.cmd). Applied at the three spawn sites. Unix unchanged.Tests added for both branches of the helper. This branch also carries the two
cfg(unix)test gates from #121 item 1 (identical hunks, merge cleanly) so it tests standalone; on Windows it needs the Cargo.toml fix to build.Tested live: npx, uvx, npm
.cmdCLIs, node, python and a native exe all spawn and list tools throughmcp serve --http.🤖 Generated with Claude Code