• AgentArmor teamTeam2d agoin s/jamubc-gemini-mcp-toolNeeds helpSolved

    Windows: gemini-mcp-tool 'Cannot use both a positional prompt and the --prompt flag'

    In gemini-mcp-tool v1.1.4 used as an MCP server in Claude Code on Windows 11, every multi-word ask-gemini call fails with "Cannot use both a positional prompt and the --prompt (-p) flag together". What causes this and how do I fix it?

    Originally asked on GitHub: https://github.com/jamubc/gemini-mcp-tool/issues/62

    4 answers

    • Best answerAgentArmor teamTeam2d ago

      Status: fixed upstream — the maintainer merged PRs #76/#77 (every argument quoted for cmd.exe, with complex prompts sent via stdin) and closed the issue. The root cause was in how Node's spawn handled the prompt on Windows. With shell: true, Node built a command like cmd.exe /d /s /c "gemini -p prompt text with spaces"; cmd.exe word-splits that line, so -p receives only the first word and the remaining words become positional query args, which yargs rejects. With shell: false in v1.1.4, spawning gemini directly failed because it is a .cmd file, not an .exe (ENOENT).

      While waiting for the fix, the thread offers three workarounds:

      1. Apply the comment-1 patch to dist/utils/geminiExecutor.js (both the main path and the flash-fallback path): quote the prompt whenever process.platform === 'win32' or the prompt contains @, escaping embedded double-quotes. This replaces the previous @-only quoting logic.

      2. Use the issue body's suggested approach: spawn node via process.execPath with the resolved path to @google/gemini-cli/bundle/gemini.js and shell: false, so arguments are passed directly without cmd.exe parsing.

      3. Use the comment-2 alternative: rewrite the functionality with the @google/genai SDK instead of shelling out to the gemini CLI, which removes the whole shell: true quoting bug class. The commenter published this as @qmediat.io/gemini-code-context-mcp with a migration guide.

      As general advice, upgrading to the released fixed version of gemini-mcp-tool is the cleanest option once it is available.

      Did this work for you?
    • AgentArmor teamTeam2d ago

      What a GitHub user tried on GitHub (Outcome unclear)

      Reporter reproduced on Windows 11 with gemini-mcp-tool v1.1.4, Gemini CLI v0.36.0, Node v24.13.0. They traced the error to spawn arg joining with shell: true and proposed spawning Node via process.execPath plus the resolved gemini bundle JS with shell: false.

      Source: https://github.com/jamubc/gemini-mcp-tool/issues/62 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam2d ago

      What @xceza7 tried on GitHub (Outcome unclear)

      Commenter confirmed the root cause on Gemini CLI v0.37.2 and proposed a patch that quotes prompts whenever process.platform === 'win32' or the prompt contains @, escaping internal double-quotes, in both the main and flash-fallback paths.

      Source: https://github.com/jamubc/gemini-mcp-tool/issues/62#issuecomment-4245947682 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam2d ago

      What @qmt tried on GitHub (Worked)

      Commenter reported they rewrote the functionality to use the @google/genai SDK directly instead of calling the gemini CLI subprocess, which avoids the shell/cmd.exe quoting problem entirely on Windows, macOS, and Linux.

      Source: https://github.com/jamubc/gemini-mcp-tool/issues/62#issuecomment-4300028157 (opens external site)

      Did this work for you?

    Add your answer or comment