还在为 Claude 的上下文窗口不够大,无法处理大型代码库而烦恼吗?Gemini MCP Server 横空出世,它就像一位经验丰富的架构师,一位资深的代码审查员,一位无所不能的调试专家,与 Claude 强强联合,帮你打造一支顶尖的 AI 开发团队。它能让 Claude 直接访问 Google 的 Gemini 2.5 Pro,赋予其强大的代码分析、问题解决和深度思考能力。
**核心功能与特点:**
* **突破上下文限制:** Gemini 2.5 Pro 拥有 100 万 tokens 的超大上下文窗口,可以一次性分析整个代码库,轻松驾驭大型项目。
* **智能文件处理:** 自动读取文件和目录,智能过滤无关文件,并有效管理 token 数量,让你专注于核心代码。
* **多种开发利器:** 内置多种实用工具,满足你不同的开发需求:
* **chat:** 与 Gemini 协同思考,碰撞灵感,验证方案,就像一位资深的开发伙伴。
* **think\_deeper:** 扩展 Claude 的推理能力,深入分析复杂问题,发现潜在的风险和漏洞。
* **review\_code:** 对代码进行专业、全面的审查,提供可操作的反馈,确保代码质量。
* **review\_changes:** 在提交代码前进行验证,发现细微的 bug,确保代码符合原始需求。
* **debug\_issue:** 针对棘手的问题进行专家级调试,提供完整的系统上下文,快速定位问题根源。
* **analyze:** 分析文件和代码,理解架构、模式和依赖关系,掌握项目全局。
* **动态协作:** 在分析过程中,Gemini 可以根据需要向 Claude 请求额外的上下文信息,实现更深入、更全面的分析。
* **灵活的思考模式:** 通过调整思考模式(minimal、low、medium、high、max),你可以控制 Gemini 分析的深度和 token 消耗,在质量和成本之间找到最佳平衡点。
* **清晰的输出:** 所有文件操作都使用路径,而不是内容,即使处理大型文件,也能保持终端输出的清晰。
* **强大的自定义能力:** 可以修改工具的行为,调整温度参数来改变回应的风格。
* **支持 Windows、macOS 和 Linux:** 无论你使用什么操作系统,都能轻松上手。
**快速上手指南:**
1. **准备工作:**
* **Docker 方式 (推荐):** 安装 Docker Desktop 和 Git。
* **传统方式:** 安装 Python 3.10 或更高版本和 Git。
2. **获取 Gemini API Key:** 访问 Google AI Studio 并生成 API key。为了获得最佳效果,建议使用付费 API key。
3. **克隆代码仓库:**
“`bash
git clone https://github.com/BeehiveInnovations/gemini-mcp-server.git
cd gemini-mcp-server
“`
4. **选择安装方式:**
* **Docker 方式 (推荐):**
* 运行 `setup-docker-env.sh` (macOS/Linux) 或 `setup-docker-env.bat/ps1` (Windows) 生成 `.env` 文件。
* 编辑 `.env` 文件,添加你的 Gemini API key。
* 构建 Docker 镜像:`docker build -t gemini-mcp-server .`
* **传统方式:**
* 运行 `setup.sh` (macOS/Linux) 或 `setup.bat` (Windows) 安装依赖。
5. **配置 Claude Desktop:**
* 找到你的 `claude_desktop_config.json` 文件。
* 根据你的安装方式,添加相应的配置信息。
* **Docker 配置示例:**
“`json
{
“mcpServers”: {
“gemini”: {
“command”: “docker”,
“args”: [
“run”,
“–rm”,
“-i”,
“–env-file”,
“/path/to/gemini-mcp-server/.env”,
“-v”,
“/path/to/your/project:/workspace:ro”,
“gemini-mcp-server:latest”
]
}
}
}
“`
* **传统配置示例 (macOS/Linux):**
“`json
{
“mcpServers”: {
“gemini”: {
“command”: “/Users/YOUR_USERNAME/gemini-mcp-server/run_gemini.sh”,
“env”: {
“GEMINI_API_KEY”: “your-gemini-api-key-here”
}
}
}
}
“`
6. **重启 Claude Desktop:** 完全退出并重启 Claude Desktop,使配置生效。
7. **连接到 Claude Code:** 运行 `claude mcp add-from-claude-desktop -s user`。
8. **开始使用:** 直接用自然语言向 Claude 提问,例如:
* “Use gemini to think deeper about this architecture design”
* “Get gemini to review this code for security issues”
* “Get gemini to debug why this test is failing”
**工具选择小贴士:**
* **需要思考伙伴?** 使用 `chat`。
* **需要更深入的思考?** 使用 `think_deeper`。
* **代码需要审查?** 使用 `review_code`。
* **预提交验证?** 使用 `review_changes`。
* **遇到问题?** 使用 `debug_issue`。
* **想要理解代码?** 使用 `analyze`。
**Docker 方式的优势:**
* 无需安装 Python,简化配置过程。
* 提供一致的运行环境,避免平台差异。
* 方便更新,只需拉取最新的镜像或重新构建。
* 隔离依赖,避免与系统 Python 包冲突。
**Windows 用户指南:**
* **原生 Windows 方式 (推荐):** 安装 Python 并配置环境变量。
* **使用 WSL:** 在 WSL 中安装 Python 并克隆代码仓库。
**使用场景举例:**
* **代码审查:** “Use gemini to review auth.py for issues”
* **安全审查:** “Get gemini to review auth/ focusing on authentication”
* **调试:** “Use gemini to debug this TypeError: ‘NoneType’ object has no attribute ‘split'”
* **架构分析:** “Get gemini to do an architecture analysis of the src/ directory”
* **预提交验证:** “Use gemini to review my pending changes before I commit”
* **性能优化:** “Review my changes for the API refactoring task. Get gemini to check for incomplete implementations or missing test coverage. Update the code based on gemini’s findings.”
* **漏洞修复:** “I’ve implemented the user authentication feature. Use gemini to review all pending changes across the codebase to ensure they align with the security requirements. Fix any issues gemini identifies before committing.”
**高级技巧:**
* **自然语言触发:** 直接使用自然语言与 Gemini 交互,无需记忆复杂的命令。
* **自动工具选择:** Claude 会根据你的请求自动选择合适的工具。
* **动态上下文请求:** Gemini 可以根据需要向 Claude 请求额外的上下文信息。
**通过 Gemini MCP Server,你可以:**
* **大幅提升 Claude 的代码处理能力。**
* **提高代码质量,减少 Bug。**
* **加速开发流程,提高效率。**
* **打造一支强大的 AI 开发团队,应对各种挑战。**
**Gemini MCP Server,让你的 Claude 更加强大,助你成为 AI 开发领域的佼佼者!**
BeehiveInnovations/gemini-mcp-server: The power of Gemini + Claude Code in one. Augments Claude’s extended thinking with Gemini’s perspective.
https://github.com/BeehiveInnovations/gemini-mcp-server
暂无评论内容