最新版本 v1.0.21 - 解决了跨终端兼容性问题和 fetch-chunk 格式错误
这是一个与 Windows 兼容的模型上下文协议 (MCP) 服务器,使AI助手能够与 Google 的 Gemini CLI 进行交互。这是专门为在 Windows 环境中无缝运行而设计的固定版本,并支持 PowerShell。
注意:这是对原始 gemini-mcp-tool 的增强版本,针对 Windows 进行了特定修复和改进。
powershellPath 参数,允许用户自定义 PowerShell 可执行路径spawn powershell.exe ENOENT 问题executeCommandWithPipedInput 函数中的 args 变量问题@filename 语法分析文件此 Windows 固定版本解决了以下问题:
在使用此工具之前,请确保您已具备以下条件:
node --version # 应该是 v16+
npm install -g @google/generative-ai-cli
# 验证安装
gemini --version
# 使用最新版本(推荐)
npx gemini-mcp-tool-windows-fixed@1.0.21
# 或使用最新版本标签
npx -y gemini-mcp-tool-windows-fixed@latest
# 安装最新版本
npm install -g gemini-mcp-tool-windows-fixed@1.0.21
# 运行工具
gemini-mcp-tool-windows-fixed
如果您之前安装了旧版本:
# 卸载旧版本并安装最新版本
npm uninstall -g gemini-mcp-tool-windows-fixed
npm cache clean --force
npm install -g gemini-mcp-tool-windows-fixed@1.0.21
# Claude Code 的单命令设置
claude mcp add gemini-cli -- npx -y gemini-mcp-tool-windows-fixed@1.0.21
验证安装:
在 Claude Code 中键入 /mcp 来验证 gemini-cli MCP 是否处于活动状态。<mcreference link="https://github.com/jamubc/gemini-mcp-tool" index="1">1</mcreference>
如果您已经在 Claude Desktop 中配置好了:
claude mcp add-from-claude-desktop
%APPDATA%\Trae\User\mcp.json{
"mcpServers": {
"gemini-cli": {
"name": "gemini-cli",
"description": "Windows 兼容的 Gemini MCP 工具",
"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"
}
}
}
%APPDATA%\Claude\claude_desktop_config.json{
"mcpServers": {
"gemini-cli": {
"command": "npx",
"args": ["-y", "gemini-mcp-tool-windows-fixed@1.0.21"],
"env": {
"GEMINI_API_KEY": "YOUR_ACTUAL_API_KEY_HERE"
}
}
}
}
将上述配置中的 YOUR_ACTUAL_API_KEY_HERE 替换为您实际的 API 密钥。
# 临时(当前会话)
$env:GEMINI_API_KEY = "your-actual-api-key"
# 永久(用户级别)
[Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "your-actual-api-key", "User")
# 验证
echo $env:GEMINI_API_KEY
Claude Desktop:
%APPDATA%\Claude\claude_desktop_config.json~/Library/Application Support/Claude/claude_desktop_config.json~/.config/claude/claude_desktop_config.jsonTrae AI:
%APPDATA%\Trae\User\mcp.json此 MCP 服务器为 AI 助手提供了以下工具:
ask-gemini与 Google Gemini 进行分析和提问。
参数:
prompt(必需):分析请求。使用 @ 语法引用文件model(可选):要使用的 Gemini 模型(默认:gemini-2.5-pro)sandbox(可选):启用沙箱模式以安全地执行代码changeMode(可选):启用结构化更改模式chunkIndex(可选):继续的块索引chunkCacheKey(可选):继续的缓存键brainstorm使用各种头脑风暴框架生成创意想法。
参数:
prompt(必需):头脑风暴挑战或问题model(可选):要使用的 Gemini 模型methodology(可选):框架(divergent、convergent、scamper、design-thinking、lateral、auto)domain(可选):领域背景(software、business、creative 等)constraints(可选):已知限制或需求existingContext(可选):背景信息ideaCount(可选):要生成的想法数量(默认:12)includeAnalysis(可选):是否包括可行性分析(默认:true)fetch-chunk从 changeMode 响应中检索缓存的块。
参数:
cacheKey(必需):初始响应中的缓存键chunkIndex(必需):要检索的块索引(基于 1)timeout-test测试防止超时机制。
参数:
duration(必需):持续时间(毫秒,最小值:10ms)ping测试与服务器的连接。
参数:
prompt(可选):要回显的消息帮助显示有关可用工具的帮助信息。
一旦配置完成,您可以通过您的 MCP 客户端使用以下工具:
带有文件引用(使用 @ 语法):
一般问题(无文件):
使用 Gemini CLI 的沙箱模式(-s):<mcreference link="https://github.com/jamubc/gemini-mcp-tool" index="2">2</mcreference> 沙箱模式允许您在一个隔离的环境中安全地测试代码更改、运行脚本或执行潜在风险的操作。
您可以在 Claude Code 的界面中直接使用这些命令(尚未测试与其他客户端的兼容性):
/analyze:使用 Gemini 分析文件或目录,或提出一般问题
prompt(必需):分析提示。使用 @ 语法包含文件(例如,/analyze prompt:@src/ 概述这个目录)或提出一般问题(例如,/analyze prompt:请使用网络搜索查找最新的新闻故事)/sandbox:在 Gemini 的沙箱环境中安全地测试代码或脚本
prompt(必需):代码测试请求(例如,/sandbox prompt:创建并运行一个处理 CSV 数据的 Python 脚本 或 /sandbox prompt:@script.py 安全地测试这个脚本)/帮助:显示 Gemini CLI 的帮助信息
/ping:测试与服务器的连接
message(可选):要回显的消息ask-gemini:发送提示给 Gemini
"解释 MCP 是如何工作的"
analyze-file:使用 @filename 语法分析特定文件
"分析 @package.json 并提出改进建议"
sandbox-mode:在安全环境中执行代码
"在沙箱模式下运行这段 Python 代码:print('Hello World')"
此版本包括以下 Windows 特定改进:
.env 文件加载和环境变量处理gemini -p "你好,你好吗?"
npx -y gemini-mcp-tool-windows-fixed
# 应显示:[GMCPT] Gemini CLI MCP 服务器(固定版)已启动
npm install -g @google/generative-ai-cli
# 检查 API 密钥是否已设置
echo $env:GEMINI_API_KEY
# 如果为空则设置
$env:GEMINI_API_KEY = "your-api-key"
# 检查执行策略
Get-ExecutionPolicy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
对于详细的故障排除,请参阅 INSTALL-GUIDE.md。
此版本包括多个 Windows 特定改进:
欢迎贡献!请:
MIT 许可证 - 详情请参阅 LICENSE 文件。
如果您遇到任何问题或有任何疑问:
为 Windows 开发者制作 ❤️
注意:这是原始 gemini-mcp-tool 的 Windows 优化分叉。对于其他平台,请考虑使用 原始版本。