Skip to content

Commit bdc60fa

Browse files
fix: resolve MCP server execution on Windows with node version managers (RooCodeInc#1246) (RooCodeInc#4711)
Co-authored-by: Daniel Riccio <[email protected]>
1 parent 347a292 commit bdc60fa

File tree

2 files changed

+383
-2
lines changed

2 files changed

+383
-2
lines changed

src/services/mcp/McpHub.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,25 @@ export class McpHub {
579579
})) as typeof config
580580

581581
if (configInjected.type === "stdio") {
582+
// On Windows, wrap commands with cmd.exe to handle non-exe executables like npx.ps1
583+
// This is necessary for node version managers (fnm, nvm-windows, volta) that implement
584+
// commands as PowerShell scripts rather than executables.
585+
// Note: This adds a small overhead as commands go through an additional shell layer.
586+
const isWindows = process.platform === "win32"
587+
588+
// Check if command is already cmd.exe to avoid double-wrapping
589+
const isAlreadyWrapped =
590+
configInjected.command.toLowerCase() === "cmd.exe" || configInjected.command.toLowerCase() === "cmd"
591+
592+
const command = isWindows && !isAlreadyWrapped ? "cmd.exe" : configInjected.command
593+
const args =
594+
isWindows && !isAlreadyWrapped
595+
? ["/c", configInjected.command, ...(configInjected.args || [])]
596+
: configInjected.args
597+
582598
transport = new StdioClientTransport({
583-
command: configInjected.command,
584-
args: configInjected.args,
599+
command,
600+
args,
585601
cwd: configInjected.cwd,
586602
env: {
587603
...getDefaultEnvironment(),

0 commit comments

Comments
 (0)