File tree Expand file tree Collapse file tree 2 files changed +383
-2
lines changed Expand file tree Collapse file tree 2 files changed +383
-2
lines changed Original file line number Diff line number Diff 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 ( ) ,
You can’t perform that action at this time.
0 commit comments