Token导航 LogoToken导航TokenDH.com
Gerrit Code Review MCP logo
开发工具stdio官方级别未说明来源级核验

Gerrit Code Review MCP

MCP Server

@smithery/cli

该服务提供与Gerrit代码审查系统的集成,允许AI助手通过简单界面审查代码变更及其详细信息。

工具数

0

提示词数

0

GitHub Stars

38

资源数

0
代码审查版本控制PythonClaude开发工具Claude DesktopClaudeCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

cayirtepeomer

提供方

cayirtepeomer

最后核验

2026/5/17 21:07

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx -y @smithery/cli install @cayirtepeomer/gerrit-code-review-mcp --client claude

详细介绍

Gerrit审查MCP服务器

](https://smithery.ai/server/@cayirtepeomer/gerrit-code-review-mcp)

此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)
  • 比较两种变更模式之间的差异
  • 查看特定文件差异或所有更改的文件
  • 分析跨patchset版本的代码修改
  • 通过审查迭代跟踪变更的演变

提交审核反馈

submit_gerrit_review(
    change_id: str,
    message: Optional[str] = None,
    patchset_number: Optional[str] = None,
    labels: Optional[Dict[str, int]] = None,
    comments: Optional[List[Dict[str, Any]]] = None,
    notify: str = "OWNER",
)
  • 发布摘要反馈、投票标签(例如。, {"Code-Review": 1}),以及内联/文件级注释
  • 将特定补丁集或默认值设置为最新版本
  • 控制Gerrit的通知行为(notify: NONE, OWNER, OWNER_REVIEWERS, ALL)
  • 注释有效载荷接受带 path, message,以及可选的Gerrit注释字段(line, side, range, ...)

示例用法

查看完整的更改:

# Fetch latest patchset of change 23824
change = fetch_gerrit_change("23824")

提交带有投票和在线评论的审核反馈:

submit_gerrit_review(
    change_id="23824",
    message="Looks good overall",
    labels={"Code-Review": 1},
    comments=[{"path": "src/app.py", "line": 42, "message": "Nice refactor."}],
    patchset_number="2",           # optional: target a specific patchset
    notify="OWNER_REVIEWERS",      # optional: adjust notification scope
)

比较特定的补丁集:

# Compare differences between patchsets 1 and 2 for change 23824
diff = fetch_patchset_diff("23824", "1", "2")

查看特定文件更改:

# Get diff for a specific file between patchsets
file_diff = fetch_patchset_diff("23824", "1", "2", "path/to/file.swift")

先决条件

  • Python 3.10或更高版本(推荐使用Python 3.11)
  • Gerrit HTTP访问凭据
  • 根据Gerrit设置生成的HTTP密码
  • 访问 mcp[cli] 包存储库(私有包)

安装

通过Smithery安装

要安装gerrit代码,请通过以下方式自动查看Claude Desktop的mcp 史密瑟里:

npx -y @smithery/cli install @cayirtepeomer/gerrit-code-review-mcp --client claude

手动安装

  1. 克隆此存储库:
git clone 
cd gerrit-review-mcp
  1. 创建并激活虚拟环境:
# For macOS/Linux:
python -m venv .venv
source .venv/bin/activate

# For Windows:
python -m venv .venv
.venv\Scripts\activate
  1. 在可编辑模式下安装此包及其依赖项:
pip install -e .

配置

  1. 设置环境变量:
export GERRIT_HOST="gerrit.example.com"  # Your Gerrit server hostname (without https://)
export GERRIT_USER="your-username"       # Your Gerrit account username
export GERRIT_HTTP_PASSWORD="your-http-password"  # Generated HTTP password from Gerrit Settings > HTTP Credentials
export GERRIT_EXCLUDED_PATTERNS="\.pbxproj$,\.xcworkspace$,node_modules/"  # Optional: regex patterns for files to exclude from reviews
# Optional TLS configuration for custom or self-signed certificates
export GERRIT_SSL_VERIFY="true"              # Set to 'false' to skip TLS verification in constrained environments
export GERRIT_CA_BUNDLE="/path/to/ca.pem"    # Optional custom CA bundle path used when verification stays enabled
# Note: If both are set, GERRIT_CA_BUNDLE takes precedence and verification stays enabled using that bundle.

或者创建一个 .env 文件:

GERRIT_HOST=gerrit.example.com
GERRIT_USER=your-username
GERRIT_HTTP_PASSWORD=your-http-password
GERRIT_EXCLUDED_PATTERNS=\.pbxproj$,\.xcworkspace$,node_modules/
GERRIT_SSL_VERIFY=true
GERRIT_CA_BUNDLE=/path/to/ca.pem
# If both are set, the CA bundle wins.
  1. 生成HTTP密码:
  • 登录您的Gerrit web界面
  • 前往“设置”>“HTTP凭据”
  • 生成新密码
  • 将密码复制到您的环境或.env文件
  1. 配置文件排除(可选):
  • GERRIT_EXCLUDED_PATTERNS 从变更审核中排除特定文件类型
  • 使用逗号分隔的正则表达式模式(例如。, \.pbxproj$,\.xcworkspace$,node_modules/)
  • 留空或未设置以使用默认排除
  • 这有助于防止大文件的无限循环

MCP配置

要将此MCP服务器与Cursor或RooCode一起使用,您需要将其配置添加到您的 ~/.cursor/mcp.json.roo/mcp.json 文件。以下是所需的配置:

{
  "mcpServers": {
    "gerrit-review-mcp": {
      "command": "/path/to/your/workspace/gerrit-code-review-mcp/.venv/bin/python",
      "args": [
        "/path/to/your/workspace/gerrit-code-review-mcp/server.py",
        "--transport",
        "stdio"
      ],
      "cwd": "/path/to/your/workspace/gerrit-code-review-mcp",
      "env": {
        "PYTHONPATH": "/path/to/your/workspace/gerrit-code-review-mcp",
        "VIRTUAL_ENV": "/path/to/your/workspace/gerrit-code-review-mcp/.venv",
        "PATH": "/path/to/your/workspace/gerrit-code-review-mcp/.venv/bin:/usr/local/bin:/usr/bin:/bin"
      },
      "stdio": true
    }
  }
}

替换 /path/to/your/workspace 使用您的实际工作空间路径。例如,如果你的项目在 /Users/username/projects/gerrit-code-review-mcp,请改用该路径。

确保配置中的所有路径都指向:

  • 虚拟环境的Python解释器
  • 该项目的 server.py 文件
  • 正确的工作目录
  • PATH中的虚拟环境bin目录

实现细节

服务器使用Gerrit REST API与Gerrit交互,提供:

  • 快速可靠的变更信息检索
  • 使用HTTP摘要身份验证进行安全身份验证
  • 支持各种Gerrit REST端点
  • 干净且可维护的代码库
  • HTTPS加密用于安全通信

故障排除

如果您遇到连接问题:

  1. 验证您的HTTP密码是否设置正确 GERRIT_HTTP_PASSWORD
  2. 检查 GERRIT_HOST 设置(仅主机名,不含https://)
  3. 确保Gerrit服务器上启用了HTTPS访问
  4. 使用卷发器测试连接 /a/ 经过身份验证的API调用的前缀:
   curl -u "your-username:your-http-password" https://your-gerrit-server.com/a/changes/?q=status:open
  1. 验证您帐户的Gerrit访问权限

HTTP凭据身份验证问题

如果您在身份验证方面遇到问题,请检查您的Gerrit配置 gitBasicAuthPolicy = HTTP (或 HTTP_LDAP).

使用自签名证书

  • GERRIT_SSL_VERIFY=false 当Gerrit使用缺少必需的使用者备选名称(SAN)条目的内部颁发证书时,禁用TLS验证。
  • 通过提供自定义证书包 GERRIT_CA_BUNDLE=/path/to/ca.pem 在信任私有CA的同时保持验证功能。
  • 将禁用验证视为临时解决方法,直到为您访问的Gerrit主机名颁发具有匹配SAN的证书。

许可证

该项目根据MIT许可证获得许可。

测试

该项目包括使用测试容器python进行可靠的跨平台测试的全面Docker集成测试。

运行测试

要运行完整的测试套件:

# Install development dependencies
pip install -e ".[dev]"

# Run all tests
pytest

# Run only integration tests
pytest -m integration

# Run with verbose output
pytest -v

# Run with coverage
pytest --cov=. --cov-report=html

测试环境变量

以下环境变量可用于配置测试行为:

  • TEST_STARTUP_TIMEOUT:容器启动超时(秒)(默认值:30)
  • TEST_LOGS_SETTLE_DELAY:检查日志前的延迟(秒)(默认值:0)
  • DOCKER_HOST:远程Docker的Docker守护进程主机(可选)

例子:

# Run tests with custom timeouts
TEST_STARTUP_TIMEOUT=60 TEST_LOGS_SETTLE_DELAY=1 pytest tests/test_docker_integration.py -v

Docker要求

Docker集成测试需要:

  • Docker守护进程正在运行并可访问
  • Docker套接字可在 /var/run/docker.sock (Linux/macOS)或 DOCKER_HOST
  • 足够的权限来构建和运行容器

如果Docker不可用,测试将自动跳过。

CI/CD集成

对于CI/CD环境,请确保:

  • Docker中的Docker(DinD)服务可用
  • Docker套接字已挂载或 DOCKER_HOST 已配置
  • 为较慢的环境设置了足够的超时值

贡献

我们欢迎捐款!拜托:

  1. 分叉存储库
  2. 创建要素分支
  3. 进行更改
  4. 运行测试套件以确保一切正常
  5. 提交拉取请求

目录标签

目录标签

代码审查版本控制PythonClaude开发工具本地部署Gerrit集成AI辅助

支持客户端

Claude DesktopClaudeCursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

部署方式(deploymentType,部署类型)

remote-capable

来源包(packageName,安装包名)

@smithery/cli

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiononeremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP