Skip to content

Bug: Deprecated -p flag causes "Cannot use both positional prompt and --prompt flag" error #48

Closed

Description

@samuelgudi

Bug: Deprecated -p flag causes "Cannot use both positional prompt and --prompt flag" error

Environment

  • OS: Windows 11
  • Node.js: v22.16.0
  • Gemini CLI: v0.23.0
  • @jamubc/gemini-mcp-tool

Problem

When using the MCP tool with Gemini CLI v0.23.0+, the following error occurs:

Error executing ask-gemini: Command failed with exit code 1: Cannot use both a positional prompt and the --prompt (-p) flag together

This happens because Gemini CLI has deprecated the -p/--prompt flag in favor of positional arguments:

-p, --prompt  [deprecated: Use the positional prompt instead. This flag will be removed in a future version.]

Root Cause

In dist/utils/geminiExecutor.js, the prompt is passed using the deprecated flag:

// Line ~89
args.push(CLI.FLAGS.PROMPT, finalPrompt);

// Line ~113 (fallback)
fallbackArgs.push(CLI.FLAGS.PROMPT, fallbackPrompt);

Where CLI.FLAGS.PROMPT = "-p" (defined in constants.js).

Suggested Fix

Change from flag-based to positional argument:

// Before
args.push(CLI.FLAGS.PROMPT, finalPrompt);

// After
args.push(finalPrompt);

Same fix needed for the fallback case:

// Before
fallbackArgs.push(CLI.FLAGS.PROMPT, fallbackPrompt);

// After
fallbackArgs.push(fallbackPrompt);

Workaround

Users can manually patch the installed package:

# Find and fix the file in npx cache
find ~/AppData/Local/npm-cache/_npx -name "geminiExecutor.js" \
  -exec sed -i 's/args.push(CLI.FLAGS.PROMPT, finalPrompt);/args.push(finalPrompt);/g' {} \; \
  -exec sed -i 's/fallbackArgs.push(CLI.FLAGS.PROMPT, fallbackPrompt);/fallbackArgs.push(fallbackPrompt);/g' {} \;

Additional Context

This issue affects all MCP wrapper packages for Gemini CLI that use the -p flag, as Google has deprecated it in CLI version 0.23.0. The positional argument approach is now the recommended way to pass prompts.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions