此 MCP 服务器提供了与 Gerrit 代码审查系统集成的功能,允许 AI 助手通过简单的接口查看和评估代码变更及其详细信息,极大地提升了代码审查的效率和便捷性。
此 MCP 服务器提供了与 Gerrit 代码审查系统集成的功能,允许 AI 助手通过简单的接口查看和评估代码变更及其详细信息。在使用前,请确保满足以下先决条件:
该服务器提供了一套精简的代码审查工具:
fetch_gerrit_change(change_id: str, patchset_number: Optional[str] = None)
fetch_patchset_diff(change_id: str, base_patchset: str, target_patchset: str, file_path: Optional[str] = None)
使用以下命令安装和管理此包:
smith install @cayirtepeomer/gerrit-code-review-mcp
git clone https://github.com/cayirtepeomer/gerrit-code-review-mcp.git
cd gerrit-code-review-mcp
pip install -r requirements.txt
审查完整的变更:
# 获取变更 23824 的最新补丁集
change = fetch_gerrit_change("23824")
# 比较变更 23824 中补丁集 1 和 2 的差异
diff = fetch_patchset_diff("23824", "1", "2")
# 获取 change_id 下 file_path 文件在 base 到 target 补丁集的修改内容
content_diff = fetch_patchset_diff(change_id, base, target, file_path=file_path)
在项目的根目录下创建一个 .env 文件,并添加以下内容:
GERRIT_HOST=your-gerrit-host
GERRIT_USERNAME=username
GERRIT_HTTP_PASSWORD=http-password
将 your-gerrit-host 替换为您的 Gerrit 服务器地址,例如:https://gerrit.example.com
在项目的根目录下创建或修改 config.json 文件,并添加以下内容:
{
"servers": {
"gerrit-code-review-mcp": {
"host": "localhost",
"port": 8080,
"ssl": false,
"auth": {
"type": "digest",
"username": "your-username",
"password": "your-http-password"
}
}
}
}
如果遇到连接问题:
GERRIT_HOST 设置。curl -u "username:http-password" https://your-gerrit-host/a/changes/
该服务器使用 Gerrit REST API 进行交互,具备以下特点:
此项目采用 MIT 许可证。
我们欢迎任何贡献!请按照以下步骤操作: