Skip to main content
Glama
Gemini CLI MCP Server

Gemini CLI MCP Server

by orzcls

๐Ÿš€ Gemini MCP Tool - Windows Fixed Version

npm version License: MIT

Latest Version v1.0.21 - Fixed cross-terminal compatibility issues and fetch-chunk format errors

A Windows-compatible Model Context Protocol (MCP) server that enables AI assistants to interact with Google's Gemini CLI. This is a fixed version specifically designed to work seamlessly on Windows environments with PowerShell support.

Note: This is an enhanced version of the original gemini-mcp-tool with Windows-specific fixes and improvements.

๐Ÿ†• Latest Updates (v1.0.21)

  • ๐Ÿ”ง Fixed Cross-Terminal Compatibility - Resolved Node.js path not found issues in different terminal environments

  • ๐Ÿ“ฆ Fixed fetch-chunk Format Error - Fixed MCP protocol format mismatch in chunked responses

  • ๐Ÿ›ก๏ธ Enhanced PATH Environment Variable Handling - Automatically adds common Node.js installation paths

  • โœ… Full Compatibility with All Terminals - Supports PowerShell, CMD, VS Code Terminal, Trae AI, CherryStudio, etc.

  • ๐Ÿš€ Improved Error Handling - Better error messages and debug output

v1.0.3 Updates

  • ๐Ÿ†• PowerShell Path Parameter Support - Added optional powershellPath parameter allowing users to customize PowerShell executable path

  • โœ… Fixed PowerShell Execution Error - Resolved spawn powershell.exe ENOENT issue

  • โœ… Improved Windows Compatibility - Automatic detection of available PowerShell versions

  • โœ… Fixed Undefined Variable Error - Fixed args variable issue in executeCommandWithPipedInput function

  • โœ… Enhanced Error Handling - Better error messages and debug output

  • โœ… Backward Compatibility - Existing configurations require no modification, automatically uses default detection logic

Related MCP server: DeepView MCP

โœจ Features

  • ๐ŸชŸ Windows Compatible: Full PowerShell support with Windows-specific path handling

  • ๐Ÿ“Š Large Context Window: Leverage Gemini's massive token window for analyzing entire codebases

  • ๐Ÿ“ File Analysis: Analyze files using @filename syntax

  • ๐Ÿ”’ Sandbox Mode: Safe code execution environment

  • ๐Ÿ”— MCP Integration: Seamless integration with MCP-compatible AI assistants (Trae AI, Claude Desktop)

  • โšก NPX Ready: Easy installation and usage with NPX

  • ๐Ÿ”ง Environment Variable Support: Flexible API key configuration

This Windows-fixed version resolves:

  • PowerShell parameter passing issues

  • Character encoding problems with Chinese/Unicode text

  • Command line argument escaping on Windows

  • Environment variable handling

๐Ÿ“‹ Prerequisites

Before using this tool, ensure you have:

  1. Node.js (v16.0.0 or higher)

    node --version  # Should be v16+
  2. Google Gemini CLI installed and configured

    npm install -g @google/generative-ai-cli
    
    # Verify installation
    gemini --version
  3. API Key: Get your API key from Google AI Studio

๐Ÿ“ฆ Installation

# Use latest version (recommended)
npx gemini-mcp-tool-windows-fixed@1.0.21

# Or use latest version tag
npx -y gemini-mcp-tool-windows-fixed@latest

Global Installation

# Install latest version
npm install -g gemini-mcp-tool-windows-fixed@1.0.21

# Run the tool
gemini-mcp-tool-windows-fixed

Updating Existing Installation

If you previously installed an older version:

# Uninstall old version and install latest
npm uninstall -g gemini-mcp-tool-windows-fixed
npm cache clean --force
npm install -g gemini-mcp-tool-windows-fixed@1.0.21

โš™๏ธ MCP Client Configuration

Claude Code (One-Line Setup)

# One-command setup for Claude Code
claude mcp add gemini-cli -- npx -y gemini-mcp-tool-windows-fixed@1.0.21

Verify Installation: Type /mcp inside Claude Code to verify the gemini-cli MCP is active. 1

Alternative: Import from Claude Desktop

If you already have it configured in Claude Desktop:

  1. Add to your Claude Desktop config (see below)

  2. Import to Claude Code:

    claude mcp add-from-claude-desktop
  1. Open: %APPDATA%\Trae\User\mcp.json

  2. Add this configuration:

{
  "mcpServers": {
    "gemini-cli": {
      "name": "gemini-cli",
      "description": "Windows-compatible Gemini MCP Tool",
      "baseUrl": "",
      "command": "npx",
      "args": [
        "-y",
        "gemini-mcp-tool-windows-fixed@1.0.21"
      ],
      "env": {
        "GEMINI_API_KEY": "YOUR_ACTUAL_API_KEY_HERE"
      },
      "isActive": true,
      "providerUrl": "https://github.com/orzcls/gemini-mcp-tool-windows-fixed"
    }
  }
}

Claude Desktop

  1. Open: %APPDATA%\Claude\claude_desktop_config.json

  2. Add this configuration:

{
  "mcpServers": {
    "gemini-cli": {
      "command": "npx",
      "args": ["-y", "gemini-mcp-tool-windows-fixed@1.0.21"],
      "env": {
        "GEMINI_API_KEY": "YOUR_ACTUAL_API_KEY_HERE"
      }
    }
  }
}

๐Ÿ”‘ API Key Configuration

Replace YOUR_ACTUAL_API_KEY_HERE in the configuration above with your actual API key.

Option 2: Environment Variable

# Temporary (current session)
$env:GEMINI_API_KEY = "your-actual-api-key"

# Permanent (user level)
[Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "your-actual-api-key", "User")

# Verify
echo $env:GEMINI_API_KEY

Configuration File Locations

Claude Desktop:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Linux: ~/.config/claude/claude_desktop_config.json

Trae AI:

  • Windows: %APPDATA%\Trae\User\mcp.json

๐Ÿ› ๏ธ Available Tools

This MCP server provides the following tools for AI assistants:

1. ask-gemini

Interact with Google Gemini for analysis and questions.

Parameters:

  • prompt (required): The analysis request. Use @ syntax for file references

  • model (optional): Gemini model to use (default: gemini-2.5-pro)

  • sandbox (optional): Enable sandbox mode for safe code execution

  • changeMode (optional): Enable structured change mode

  • chunkIndex (optional): Chunk index for continuation

  • chunkCacheKey (optional): Cache key for continuation

2. brainstorm

Generate creative ideas using various brainstorming frameworks.

Parameters:

  • prompt (required): Brainstorming challenge or question

  • model (optional): Gemini model to use

  • methodology (optional): Framework (divergent, convergent, scamper, design-thinking, lateral, auto)

  • domain (optional): Domain context (software, business, creative, etc.)

  • constraints (optional): Known limitations or requirements

  • existingContext (optional): Background information

  • ideaCount (optional): Number of ideas to generate (default: 12)

  • includeAnalysis (optional): Include feasibility analysis (default: true)

3. fetch-chunk

Retrieve cached chunks from changeMode responses.

Parameters:

  • cacheKey (required): Cache key from initial response

  • chunkIndex (required): Chunk index to retrieve (1-based)

4. timeout-test

Test timeout prevention mechanisms.

Parameters:

  • duration (required): Duration in milliseconds (minimum: 10ms)

5. ping

Test connection to the server.

Parameters:

  • prompt (optional): Message to echo back

6. Help

Display help information about available tools.

๐ŸŽฏ Usage Examples

Once configured, you can use the following tools through your MCP client:

Natural Language Examples 2

With File References (using @ syntax):

  • "ask gemini to analyze @src/main.js and explain what it does"

  • "use gemini to summarize @. the current directory"

  • "analyze @package.json and tell me about dependencies"

General Questions (without files):

  • "ask gemini to search for the latest tech news"

  • "use gemini to explain div centering"

  • "ask gemini about best practices for React development related to @file_im_confused_about"

  • "use gemini to explain index.html"

  • "understand the massive project using gemini"

  • "ask gemini to search for latest news"

Using Gemini CLI's Sandbox Mode (-s): 2 The sandbox mode allows you to safely test code changes, run scripts, or execute potentially risky operations in an isolated environment.

  • "use gemini sandbox to create and run a Python script that processes data"

  • "ask gemini to safely test @script.py and explain what it does"

  • "use gemini sandbox to install numpy and create a data visualization"

  • "test this code safely: Create a script that makes HTTP requests to an API"

Slash Commands (for Claude Code Users) 2

You can use these commands directly in Claude Code's interface (compatibility with other clients has not been tested):

  • /analyze: Analyzes files or directories using Gemini, or asks general questions

    • prompt (required): The analysis prompt. Use @ syntax to include files (e.g., /analyze prompt:@src/ summarize this directory) or ask general questions (e.g., /analyze prompt:Please use a web search to find the latest news stories)

  • /sandbox: Safely tests code or scripts in Gemini's sandbox environment

    • prompt (required): Code testing request (e.g., /sandbox prompt:Create and run a Python script that processes CSV data or /sandbox prompt:@script.py Test this script safely)

  • /help: Displays the Gemini CLI help information

  • /ping: Tests the connection to the server

    • message (optional): A message to echo back

Available Tools

  • ask-gemini: Send prompts to Gemini

    "Explain how MCP works"
  • analyze-file: Analyze specific files using @filename syntax

    "Analyze @package.json and suggest improvements"
  • sandbox-mode: Execute code in a safe environment

    "Run this Python code in sandbox mode: print('Hello World')"

๐Ÿ”ง Windows-Specific Fixes

This version includes the following Windows-specific improvements:

  1. PowerShell Parameter Handling: Fixed argument passing to avoid parameter splitting

  2. Character Encoding: Proper UTF-8 handling for Chinese and Unicode characters

  3. Quote Escaping: Correct escaping of quotes in command arguments

  4. Environment Variables: Improved .env file loading and environment variable handling

  5. Path Resolution: Windows-compatible path handling

๐Ÿงช Testing Installation

1. Test Gemini CLI

gemini -p "Hello, how are you?"

2. Test MCP Tool

npx -y gemini-mcp-tool-windows-fixed
# Should show: [GMCPT] Gemini CLI MCP Server (Fixed) started

3. Test MCP Integration

  1. Restart your MCP client (Trae AI, Claude Desktop)

  2. Try asking: "Use gemini to explain what MCP is"

  3. Check for successful responses

๐Ÿ› Troubleshooting

Common Issues

"Command not found: gemini"

npm install -g @google/generative-ai-cli

"API key not found"

# Check if API key is set
echo $env:GEMINI_API_KEY

# Set if empty
$env:GEMINI_API_KEY = "your-api-key"

"Permission denied"

# Check execution policy
Get-ExecutionPolicy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

For detailed troubleshooting, see INSTALL-GUIDE.md.

๐Ÿ”ง Windows-Specific Fixes

This version includes several Windows-specific improvements:

  • PowerShell Integration: Native PowerShell command execution

  • Path Handling: Proper Windows path resolution

  • Environment Variables: Enhanced environment variable support

  • Error Handling: Better error messages for Windows environments

  • Dependency Management: Simplified dependency structure

๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Test on Windows environments

  4. Submit a pull request

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the Issues page

  2. Create a new issue with detailed information about your problem

  3. Include your Windows version, Node.js version, and error messages


Made with โค๏ธ for Windows developers

Note: This is a Windows-optimized fork of the original gemini-mcp-tool. For other platforms, consider using the original version.

Available Tools

6 tools
ask-geminiC

model selection [-m], sandbox [-s], and changeMode:boolean for providing edits

Inputs: prompt (required), model, sandbox, changeMode, +3 more.

brainstormC

Generate novel ideas with dynamic context gathering. --> Creative frameworks (SCAMPER, Design Thinking, etc.), domain context integration, idea clustering, feasibility analysis, and iterative refinement.

Inputs: prompt (required), model, methodology, domain, +5 more.

fetch-chunkA

Retrieves cached chunks from a changeMode response. Use this to get subsequent chunks after receiving a partial changeMode response.

Inputs: cacheKey (required), chunkIndex (required).

HelpC

receive help information

Inputs: no named parameters.

pingC

Echo

Inputs: prompt.

timeout-testA

Test timeout prevention by running for a specified duration

Inputs: duration (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    C2.6/5.0

    Scored across 6 tools

    Disambiguation3/5

    The tools have distinct primary purposes (e.g., ask-gemini for model queries, brainstorm for idea generation, fetch-chunk for data retrieval), but some overlap exists in communication functions: Help provides general assistance while ping serves as a connectivity test, which could be confused for basic diagnostic purposes. The descriptions clarify their differences, but the boundaries between support tools are not perfectly sharp.

    Naming Consistency2/5

    Naming conventions are inconsistent across the set: ask-gemini and fetch-chunk use kebab-case with descriptive verbs, brainstorm is a single word, Help uses PascalCase, ping is lowercase, and timeout-test mixes kebab-case with a hyphen. There is no uniform pattern in verb usage or casing, making the tool names appear chaotic and unpredictable.

    Tool Count4/5

    With 6 tools, the count is reasonable for a CLI server focused on Gemini interactions and utility functions. It covers core operations like querying, idea generation, and testing without being overly bloated, though it might feel slightly thin if expanded to more advanced Gemini features. The scope aligns well with the provided tools.

    Completeness3/5

    The tool set covers basic interactions with Gemini (ask-gemini, brainstorm) and includes utility functions (fetch-chunk, Help, ping, timeout-test), but there are notable gaps for a comprehensive CLI server: missing operations for managing conversations, handling errors, or configuring settings. It supports core workflows but lacks full lifecycle coverage, which could limit agent effectiveness in complex scenarios.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A server implementing the Model Context Protocol that enables AI assistants like Claude to interact with Google's Gemini API for text generation, text analysis, and chat conversations.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables IDEs like Cursor and Windsurf to analyze large codebases using Gemini's extensive context window.
      65
      MIT
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      A server that allows interaction with Google's Gemini AI through the Gemini CLI tool using the Model Context Protocol, providing a standardized interface for querying Gemini with various options and configurations.
      -