使用说明
Gemini MCP服务器
MCP(模型上下文协议)服务器与Google Gemini CLI集成,用于开发工作流程中的AI二次意见和验证。
特性
- 🤖 AI第二意见:从谷歌的Gemini人工智能中获得替代观点
- 🔍 自动不确定度检测:检测到不确定性时触发协商
- ⚡ 速率限制:限制内置速率以防止API滥用
- 🛡️ 可配置模型:支持不同的Gemini型号
- 📊 咨询记录:使用时间戳跟踪所有人工智能咨询
快速开始
使用uvx(推荐)
无需安装即可直接运行:
# Run in current directory
uvx gemini-mcp-server
# Run with specific project root
uvx gemini-mcp-server --project-root /path/to/project
地方发展
# Clone the repository
git clone https://github.com/taehun-kmu/gemini-mcp-server
cd gemini-mcp-server
# Install with uv
uv pip install -e .
# Run the server
gemini-mcp-server
先决条件
- Node.js 18+ -Gemini CLI需要
- Python 3.8+ -MCP服务器需要
- Gemini CLI -安装并验证:
# Install Gemini CLI
npm install -g @google/gemini-cli
# Authenticate (run once)
gemini
配置
创建一个 gemini-config.json 项目根目录中的文件:
{
"enabled": true,
"auto_consult": true,
"cli_command": "gemini",
"timeout": 60,
"rate_limit_delay": 2.0,
"model": "gemini-2.5-flash",
"log_consultations": true
}
环境变量
用环境变量覆盖配置:
GEMINI_ENABLED:启用/禁用集成GEMINI_AUTO_CONSULT:启用/禁用自动咨询GEMINI_CLI_COMMAND:CLI命令(默认值:“gemini”)GEMINI_TIMEOUT:命令超时(秒)GEMINI_RATE_LIMIT:协商之间的延迟GEMINI_MODEL:要使用的模型(默认值:“gemini-2.5-flash”)
MCP工具
服务器公开了三个MCP工具:
-
咨询师_双子座:从双子座那里获得第二意见
query:问题或主题context:附加上下文comparison_mode:请求结构化比较格式
-
双子座状态:检查集成状态和统计数据
-
toggle_gemini_auto_consult:启用/禁用自动咨询
enable:true/false或省略以切换
Claude代码集成
通过添加到MCP配置中,配置Claude Code以使用此MCP服务器:
{
"mcpServers": {
"gemini": {
"command": "uvx",
"args": ["gemini-mcp-server"],
"env": {
"GEMINI_ENABLED": "true"
}
}
}
}
注:添加 "--project-root", "/path/to/project" 如果需要指定其他项目目录,请使用args。
发展
项目结构
gemini-mcp-server/
├── gemini_mcp/
│ ├── __init__.py
│ ├── __main__.py # CLI entry point
│ ├── gemini_integration.py # Gemini integration logic
│ └── server.py # MCP server implementation
├── pyproject.toml # Package configuration
├── README.md # This file
├── LICENSE # MIT License
├── setup-gemini-integration.sh # Setup script
└── gemini-config.json # Example configuration
运行测试
# Install dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Format code
ruff format gemini_mcp
ruff check gemini_mcp
许可证
MIT许可证-有关详细信息,请参阅许可证文件。