Gemini MCP工具
](https://github.com/jamubc/gemini-mcp-tool/releases) ](https://www.npmjs.com/package/gemini-mcp-tool) ](https://www.npmjs.com/package/gemini-mcp-tool)  
📚 查看完整文档 -搜我!,示例,常见问题解答,故障排除,最佳实践
这是一个简单的模型上下文协议(MCP)服务器,允许AI助手与 Gemini CLI。它使AI能够利用Gemini庞大的令牌窗口进行大型分析,特别是使用 @ 方向语法。
- 通过claude或头脑风暴在3人的聚会中提出双子座的自然问题!
目标:直接在Claude Code中使用Gemini强大的分析功能来保存令牌和分析大文件。
先决条件
在使用此工具之前,请确保您已:
- **** (v16.0.0或更高版本)
- 谷歌Gemini CLI 已安装并配置
单线设置
claude mcp add gemini-cli -- npx -y gemini-mcp-tool验证安装
类型 /mcp 在Claude Code内部验证gemini cli MCP是否处于活动状态。
______________________________________________________________________
替代方案:从Claude Desktop导入
如果您已经在Claude Desktop中配置了它:
- 添加到您的Claude Desktop配置中:
"gemini-cli": {
"command": "npx",
"args": ["-y", "gemini-mcp-tool"]
}- 导入到克劳德代码:
claude mcp add-from-claude-desktop配置
在MCP客户端注册MCP服务器:
NPX使用(推荐)
将此配置添加到您的Claude Desktop配置文件中:
{
"mcpServers": {
"gemini-cli": {
"command": "npx",
"args": ["-y", "gemini-mcp-tool"]
}
}
}全球安装
如果全局安装,请改用此配置:
{
"mcpServers": {
"gemini-cli": {
"command": "gemini-mcp"
}
}
}配置文件位置:
- 克劳德桌面:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json - 视窗: %APPDATA%\Claude\claude_desktop_config.json - Linux: ~/.config/claude/claude_desktop_config.json
更新配置后,重新启动终端会话。
工作流示例
- 自然语言:“使用gemini解释index.html”,“了解使用gemini的大型项目”,“让gemini搜索最新消息”
- 克劳德代码:类型
/gemini-cli命令将填充到Claude Code的界面中。
使用示例
使用文件引用(使用@语法)
ask gemini to analyze @src/main.js and explain what it doesuse gemini to summarize @. the current directoryanalyze @package.json and tell me about dependencies
一般问题(无文件)
ask gemini to search for the latest tech newsuse gemini to explain div centeringask gemini about best practices for React development related to @file_im_confused_about
使用Gemini CLI的沙盒模式
沙盒模式允许您在隔离环境中安全地测试代码更改、运行脚本或执行潜在风险的操作。
use gemini sandbox to create and run a Python script that processes dataask gemini to safely test @script.py and explain what it doesuse gemini sandbox to install numpy and create a data visualizationtest this code safely: Create a script that makes HTTP requests to an API
工具(用于AI)
这些工具旨在供AI助手使用。
ask-gemini:询问谷歌双子座的观点。可用于一般问题或复杂的文件分析。
- prompt (必填):分析请求。使用 @ 语法以包括文件或目录引用(例如。, @src/main.js explain this code)或提出一般性问题(例如。, Please use a web search to find the latest news stories). - model (可选):使用Gemini模型。默认为 gemini-2.5-pro. - sandbox (可选):设置为 true 在沙盒模式下运行以安全执行代码。
sandbox-test:在Gemini的沙盒环境中安全执行代码或命令。始终在沙盒模式下运行。
- prompt (必填):代码测试请求(例如。, Create and run a Python script that... 或 @script.py Run this safely). - model (可选):使用Gemini模型。
Ping:一个简单的测试工具,可以回显消息。Help:显示Gemini CLI帮助文本。
Slash命令(用户)
您可以直接在Claude Code的界面中使用这些命令(尚未测试与其他客户端的兼容性)。
- /分析:使用Gemini分析文件或目录,或提出一般性问题。
- prompt (必填):分析提示。使用 @ 语法以包括文件(例如。, /analyze prompt:@src/ summarize this directory)或提出一般性问题(例如。, /analyze prompt:Please use a web search to find the latest news stories).
- /沙箱:在Gemini的沙盒环境中安全地测试代码或脚本。
- prompt (必填):代码测试请求(例如。, /sandbox prompt:Create and run a Python script that processes CSV data 或 /sandbox prompt:@script.py Test this script safely).
- /帮助:显示Gemini CLI帮助信息。
- /ping:测试与服务器的连接。
- message (可选):要回显的消息。
贡献
欢迎投稿!请查看我们的 贡献指南 有关如何提交pull请求、报告问题和为项目做出贡献的详细信息。
许可证
该项目根据MIT许可证获得许可。请参阅 许可证 文件以获取详细信息。
免责声明: 这是一个非官方的第三方工具,不隶属于谷歌,也不受谷歌的认可或赞助。
