Skip to content

Cannot use within Claude extension for VS Code on Cursor on Windows #40

@trustdan

Description

@trustdan

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:

  1. 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.

  2. 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

  1. Install gemini-mcp-tool on Windows via npm/npx
  2. 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"
          ]
        }
      }
    }
  3. Attempt to use any gemini-mcp-tool function
  4. Observe spawn ENOENT errors

What We've Tried

We've attempted multiple workarounds to resolve the PATH/spawn issues:

  1. ✅ Setting PATH in MCP config env object
  2. ✅ Using full path to npx.cmd
  3. ✅ Wrapping in cmd /c with explicit PATH setting
  4. ✅ Creating batch file wrapper scripts
  5. ✅ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions