Skip to content

fix(desktop): resolve Windows npx stdio MCP via node and fnm (v2) - #1017

Merged
vastsa merged 1 commit into
mainfrom
fix/mcp-stdio-windows-npx-v2
Sep 24, 2026
Merged

vastsa merged 1 commit into
mainfrom
fix/mcp-stdio-windows-npx-v2

Conversation

@vastsa

@vastsa vastsa commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Summary

Cherry-pick of #1012 with security fixes for the review findings.

Changes from the original PR

Issue Severity Fix
wrapCmdShim missing outer quotes — cmd.exe /s /c strips first+last quote, breaking paths with spaces and enabling injection Critical Wrap line in outer quotes: args: ["/d", "/s", "/c", "${line}"]
quoteWindowsCmdArg does not escape % — cmd.exe expands %VAR% inside double quotes Major arg.replace(/%/g, "%%") before quote-doubling
defaultFs.isFile falls back to existsSync which matches directories Minor Return false on statSync error; remove unused existsSync import
bun/bunx in NODE_LAUNCHERS — dead path since bun has its own install location Minor Removed from list

New test coverage

  • wrapCmdShim outer-quotes survive when .cmd path contains spaces — path with spaces + metachar args + embedded quotes
  • % escaping assertions in cmd quoting keeps metacharacters inside one argument

Test plan

  • node --test apps/desktop/test/mcp-stdio-launch.test.mjs (15 pass)
  • node --test apps/desktop/test/plugin-mcp.test.mjs plugin-child-env.test.mjs extensions-page.test.mjs (64 pass total)
  • No new typecheck errors in changed files

fixes #789
supersedes #1012

Cherry-pick PR #1012 with security fixes:

- quoteWindowsCmdArg: escape % as %% so cmd.exe does not expand env vars
- wrapCmdShim: wrap the /s /c line in outer quotes so paths with spaces
  survive cmd.exe's first/last quote stripping (prevents injection)
- defaultFs.isFile: return false on statSync error instead of existsSync
  which could match directories
- Remove bun/bunx from NODE_LAUNCHERS (dead path: bun has its own
  install location unrelated to node)

fixes #789
Copilot AI lite review requested due to automatic review settings September 24, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vastsa
vastsa merged commit 921b6d2 into main Sep 24, 2026
2 of 4 checks passed
@vastsa
vastsa deleted the fix/mcp-stdio-windows-npx-v2 branch September 27, 2026 18:39
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.

[Bug] Windows 下 npx 类型 MCP 无法启动,错误提示 command not found,但 npx 已安装且位于 PATH

2 participants