Windows-compatible MCP server that enables AI assistants to interact with Google Gemini CLI - Fixed version for Windows environments
npm install gemini-mcp-tool-windows-fixedCannot read properties of undefined 错误
gemini-2.5-pro 模型,性能更佳
powershellPath 参数,允许用户自定义 PowerShell 可执行文件路径
spawn powershell.exe ENOENT 问题
executeCommandWithPipedInput 函数中的 args 变量问题
@filename syntax
powershell
node --version # Should be v16+
`
2. Google Gemini CLI: Install the Gemini CLI tool
`powershell
npm install -g @google/generative-ai-cli
# Verify installation
gemini --version
`
3. API Key: Get your API key from Google AI Studio
📦 Installation
$3
`powershell
使用最新版本 (推荐)
npx gemini-mcp-tool-windows-fixed@1.0.4
或者使用最新版本标签
npx -y gemini-mcp-tool-windows-fixed@latest
`
$3
`powershell
安装最新版本
npm install -g gemini-mcp-tool-windows-fixed@1.0.4
运行工具
gemini-mcp-tool-windows-fixed
`
$3
如果您之前安装了旧版本:
`powershell
卸载旧版本并安装最新版本
npm uninstall -g gemini-mcp-tool-windows-fixed
npm cache clean --force
npm install -g gemini-mcp-tool-windows-fixed@1.0.3
`
⚙️ MCP Client Configuration
$3
`bash
One-command setup for Claude Code
claude mcp add gemini-cli -- npx -y gemini-mcp-tool-windows-fixed@1.0.4
`
Verify Installation:
Type /mcp inside Claude Code to verify the gemini-cli MCP is active. 1
$3
If you already have it configured in Claude Desktop:
1. Add to your Claude Desktop config (see below)
2. Import to Claude Code:
`bash
claude mcp add-from-claude-desktop
`
$3
1. Open: %APPDATA%\Trae\User\mcp.json
2. Add this configuration:
`json
{
"mcpServers": {
"gemini-cli": {
"name": "gemini-cli",
"description": "Windows-compatible Gemini MCP Tool",
"baseUrl": "",
"command": "npx",
"args": [
"-y",
"gemini-mcp-tool-windows-fixed@1.0.4"
],
"env": {
"GEMINI_API_KEY": "YOUR_ACTUAL_API_KEY_HERE"
},
"isActive": true,
"providerUrl": "https://github.com/orzcls/gemini-mcp-tool-windows-fixed"
}
}
}
`
$3
1. Open: %APPDATA%\Claude\claude_desktop_config.json
2. Add this configuration:
`json
{
"mcpServers": {
"gemini-cli": {
"command": "npx",
"args": ["-y", "gemini-mcp-tool-windows-fixed@1.0.4"],
"env": {
"GEMINI_API_KEY": "YOUR_ACTUAL_API_KEY_HERE"
}
}
}
}
`
🔑 API Key Configuration
$3
Replace YOUR_ACTUAL_API_KEY_HERE in the configuration above with your actual API key.
$3
`powershell
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
`
$3
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:
$3
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
$3
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
Retrieve cached chunks from changeMode responses.
Parameters:
- cacheKey (required): Cache key from initial response
- chunkIndex (required): Chunk index to retrieve (1-based)
$3
Test timeout prevention mechanisms.
Parameters:
- duration (required): Duration in milliseconds (minimum: 10ms)
$3
Test connection to the server.
Parameters:
- prompt (optional): Message to echo back
$3
Display help information about available tools.
🎯 Usage Examples
Once configured, you can use the following tools through your MCP client:
$3
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"
$3
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
$3
- 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
$3
`powershell
gemini -p "Hello, how are you?"
`
$3
`powershell
npx -y gemini-mcp-tool-windows-fixed
Should show: [GMCPT] Gemini CLI MCP Server (Fixed) started
`
$3
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
$3
#### "Command not found: gemini"
`powershell
npm install -g @google/generative-ai-cli
`
#### "API key not found"
`powershell
Check if API key is set
echo $env:GEMINI_API_KEY
Set if empty
$env:GEMINI_API_KEY = "your-api-key"
`
#### "Permission denied"
`powershell
Check execution policy
Get-ExecutionPolicy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
``