Windows Compatibility Issue: spawn ENOENT Error When Executing Gemini Commands
Environment
- OS: Windows 11 (Build 26200.6899)
- Node.js: Installed via nvm4w at
C:\nvm4w\nodejs
- Gemini CLI: v0.12.0 (working correctly in terminal)
- MCP Client: Claude Code (VSCode/Cursor extension)
- gemini-mcp-tool: Installed via
npx -y gemini-mcp-tool
Problem Description
The gemini-mcp-tool fails on Windows with spawn ENOENT errors when attempting to execute child processes. The error occurs consistently across all tool invocations:
Error executing ping: Failed to spawn command: spawn echo ENOENT
Error executing ask-gemini: Failed to spawn command: spawn gemini ENOENT
This happens even though:
- The
gemini CLI is correctly installed and works perfectly in terminal sessions
- The
gemini command is accessible via PATH (C:\nvm4w\nodejs\gemini.cmd)
- The MCP server starts successfully and accepts connections
Root Cause
The issue is a classic Node.js Windows compatibility problem related to how child_process.spawn() handles .cmd files and PATH resolution:
-
Missing shell: true option: On Windows, spawn() does not use a shell by default. This means it cannot find or execute .cmd or .bat files, which require cmd.exe to interpret them.
-
PATH inheritance: Even when PATH is set correctly in the parent process (the MCP server), child processes spawned without shell: true don't properly inherit or use the PATH environment variable on Windows.
Steps to Reproduce
- Install gemini-mcp-tool on Windows via npm/npx
- Configure MCP client (e.g., Claude Code) with the following
.claude.json:
{
"mcpServers": {
"gemini-cli": {
"type": "stdio",
"command": "cmd",
"args": [
"/c",
"set PATH=C:\\nvm4w\\nodejs;%PATH% && npx -y gemini-mcp-tool"
]
}
}
}
- Attempt to use any gemini-mcp-tool function
- Observe
spawn ENOENT errors
What We've Tried
We've attempted multiple workarounds to resolve the PATH/spawn issues:
- ✅ Setting PATH in MCP config
env object
- ✅ Using full path to
npx.cmd
- ✅ Wrapping in
cmd /c with explicit PATH setting
- ✅ Creating batch file wrapper scripts
- ✅ Using PowerShell wrapper
All approaches successfully launch the MCP server, but child processes spawned by gemini-mcp-tool still fail with ENOENT.
Suggested Fix
The issue needs to be fixed within the gemini-mcp-tool source code. When spawning child processes on Windows, one of these approaches should be used:
Option 1: Add shell: true to spawn calls (Recommended)
const child = spawn('gemini', args, {
shell: true, // Enable shell on Windows
...otherOptions
});
Option 2: Detect Windows and use cmd.exe wrapper
const isWindows = process.platform === 'win32';
const command = isWindows ? 'cmd' : 'gemini';
const args = isWindows ? ['/c', 'gemini', ...actualArgs] : actualArgs;
const child = spawn(command, args, otherOptions);
Option 3: Use cross-spawn package
The cross-spawn npm package handles this cross-platform compatibility automatically:
const spawn = require('cross-spawn');
const child = spawn('gemini', args, otherOptions);
Expected Behavior
The gemini-mcp-tool should work on Windows without requiring complex workarounds, similar to how it works on Unix-like systems.
Additional Context
This is a well-documented issue with Node.js on Windows:
Many popular Node.js tools use cross-spawn or conditional logic to handle Windows compatibility.
Impact
This issue prevents Windows users from using gemini-mcp-tool with Claude Code and other MCP clients, limiting the tool's accessibility and adoption on Windows platforms.
Would you be open to a PR that fixes this issue? I'd be happy to contribute a fix if that would be helpful.
Windows Compatibility Issue:
spawn ENOENTError When Executing Gemini CommandsEnvironment
C:\nvm4w\nodejsnpx -y gemini-mcp-toolProblem Description
The gemini-mcp-tool fails on Windows with
spawn ENOENTerrors when attempting to execute child processes. The error occurs consistently across all tool invocations:This happens even though:
geminiCLI is correctly installed and works perfectly in terminal sessionsgeminicommand is accessible via PATH (C:\nvm4w\nodejs\gemini.cmd)Root Cause
The issue is a classic Node.js Windows compatibility problem related to how
child_process.spawn()handles.cmdfiles and PATH resolution:Missing
shell: trueoption: On Windows,spawn()does not use a shell by default. This means it cannot find or execute.cmdor.batfiles, which requirecmd.exeto interpret them.PATH inheritance: Even when PATH is set correctly in the parent process (the MCP server), child processes spawned without
shell: truedon't properly inherit or use the PATH environment variable on Windows.Steps to Reproduce
.claude.json:{ "mcpServers": { "gemini-cli": { "type": "stdio", "command": "cmd", "args": [ "/c", "set PATH=C:\\nvm4w\\nodejs;%PATH% && npx -y gemini-mcp-tool" ] } } }spawn ENOENTerrorsWhat We've Tried
We've attempted multiple workarounds to resolve the PATH/spawn issues:
envobjectnpx.cmdcmd /cwith explicit PATH settingAll approaches successfully launch the MCP server, but child processes spawned by gemini-mcp-tool still fail with ENOENT.
Suggested Fix
The issue needs to be fixed within the gemini-mcp-tool source code. When spawning child processes on Windows, one of these approaches should be used:
Option 1: Add
shell: trueto spawn calls (Recommended)Option 2: Detect Windows and use cmd.exe wrapper
Option 3: Use cross-spawn package
The
cross-spawnnpm package handles this cross-platform compatibility automatically:Expected Behavior
The gemini-mcp-tool should work on Windows without requiring complex workarounds, similar to how it works on Unix-like systems.
Additional Context
This is a well-documented issue with Node.js on Windows:
shell: trueoption is specifically designed to solve this problem on WindowsMany popular Node.js tools use
cross-spawnor conditional logic to handle Windows compatibility.Impact
This issue prevents Windows users from using gemini-mcp-tool with Claude Code and other MCP clients, limiting the tool's accessibility and adoption on Windows platforms.
Would you be open to a PR that fixes this issue? I'd be happy to contribute a fix if that would be helpful.