Gerrit Code Review

team.gaijin由 gaijin.team 發布v1.1.3更新於 Oct 24, 2026

Capability-gated Gerrit code review tools with opt-in review notifications pushed into the session

發布方自己的服務:Review Expert

已驗證STDIO僅桌面開發者工具溝通與協作

概覽

AI 產生的概覽

一個本機 MCP 伺服器,為助理提供依能力分組的工具,用來搜尋、讀取、留言、投票和推進 Gerrit 程式碼審查變更。

可以做什麼
搜尋與讀取變更:用 Gerrit 變更查詢語法檢索,取得變更詳情、列出受影響檔案、查看單一檔案差異,並讀取附解決狀態的留言串。發布審查:一次送出頂層訊息以及行內、範圍、檔案層級和回覆留言,並可切換留言串的解決狀態。投票與狀態轉換:設定或清除 Code-Review 等標籤投票,並執行提交、放棄、還原、標記進行中或就緒。訂閱變更後,新的訊息、投票、留言串和狀態變化會主動推送到工作階段中,也可提前取消訂閱。
適用情境
適合讓助理參與 Gerrit 審查流程:整理待審變更、彙整差異和留言串、起草或張貼審查意見、投票,以及推進提交或放棄等狀態。預設為唯讀,寫入能力需明確開啟。
執行需求
以本機程序透過 stdio 執行(二進位發行版、Docker 映像或 go install),僅限桌面端。需要 Gerrit 3.13 以上執行個體,以及三個環境變數:GERRIT_URL、GERRIT_USERNAME 和 GERRIT_TOKEN(在 Gerrit 中產生的 HTTP 憑證)。能力分組、專案允許清單和通知設定透過命令列參數或其 GERRIT_MCP_* 對應變數設定。
安裝前請注意
GERRIT_TOKEN 是真实的 Gerrit HTTP 憑證,不要放進共用設定。啟用 comment、transition 等寫入分組後,會張貼同事可見的留言、投票和狀態變更;own-changes-only 預設開啟,在明確關閉前會拒絕對非本人變更執行這類操作。專案範圍由伺服器端強制。審查通知需要支援 channel 的用戶端,且屬於研究預覽功能。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Gerrit Code Review,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

go-gerrit-mcp

An MCP (Model Context Protocol) server that exposes Gerrit code review operations as capability-gated tools. An AI agent can search and read changes, publish review comments, vote, and drive change-state transitions. Every write capability is an explicit operator opt-in.

  • Transport: stdio
  • Target platform: Gerrit 3.13+, authenticated via HTTP credentials
  • Output: llmxml, semantically tagged text meant to be read by a model (see Output format)

Safety posture

Two defaults encode it:

  • Zero configuration exposes the read group only. Write capability never appears unless enabled via --groups.
  • The own-changes restriction is on by default. Even with write groups enabled, trail-leaving operations (comments, votes, state changes, anything other humans see) are refused on changes the authenticated account does not own, until the operator explicitly passes --own-changes-only=false.

An agent leaving unwanted trail on colleagues' changes is an externally visible failure; a missing capability is a locally discoverable inconvenience. The defaults are chosen accordingly. Widen deliberately:

sh
# agent may comment and vote on anyone's changes, but only within two projectsgo-gerrit-mcp --groups read,comment,transition --own-changes-only=false --projects core,infra

Install

Binary release: download the binary for your platform from GitHub Releases, make it executable, and put it on your PATH:

sh
# macOS on Apple silicon; substitute <os>_<arch> from: linux, darwin, windows x amd64, arm64curl -Lo /usr/local/bin/go-gerrit-mcp \  https://github.com/GaijinEntertainment/go-gerrit-mcp/releases/latest/download/go-gerrit-mcp_darwin_arm64chmod +x /usr/local/bin/go-gerrit-mcp

Docker:

sh
docker pull ghcr.io/gaijinentertainment/go-gerrit-mcp:latest

go install:

sh
go install dev.gaijin.team/go/go-gerrit-mcp/cmd/go-gerrit-mcp@latest

Quick start

The server reads connection identity from environment variables only; credentials never travel through flags:

VariableMeaning
GERRIT_URLBase URL of the Gerrit instance
GERRIT_USERNAMEAccount username for HTTP Basic authentication
GERRIT_TOKENHTTP credential paired with the username

Generate the credential in Gerrit under Settings → HTTP Credentials (an HTTP password, or an auth token on instances that issue them). All three variables are required; the server exits with an error naming the missing ones.

Claude Code

sh
claude mcp add gerrit \  --env GERRIT_URL=https://gerrit.example.com \  --env GERRIT_USERNAME=your-username \  --env GERRIT_TOKEN=your-http-credential \  -- go-gerrit-mcp

Any MCP client (JSON configuration)

json
{  "mcpServers": {    "gerrit": {      "command": "go-gerrit-mcp",      "args": ["--groups", "read"],      "env": {        "GERRIT_URL": "https://gerrit.example.com",        "GERRIT_USERNAME": "your-username",        "GERRIT_TOKEN": "your-http-credential"      }    }  }}

Docker

json
{  "mcpServers": {    "gerrit": {      "command": "docker",      "args": [        "run", "-i", "--rm",        "-e", "GERRIT_URL", "-e", "GERRIT_USERNAME", "-e", "GERRIT_TOKEN",        "ghcr.io/gaijinentertainment/go-gerrit-mcp:latest",        "--groups", "read"      ],      "env": {        "GERRIT_URL": "https://gerrit.example.com",        "GERRIT_USERNAME": "your-username",        "GERRIT_TOKEN": "your-http-credential"      }    }  }}

Per-project configuration in Claude Code

Everything the server needs is read from the environment: the identity variables above plus a GERRIT_MCP_* mirror for every flag (see Configuration reference). MCP server processes inherit the session environment, so in Claude Code one user-level registration turns into per-project configuration, down to different Gerrit instances with different credentials per repository.

~/.claude.json holds the registration, with no env block:

json
{  "mcpServers": {    "gerrit": {      "command": "go-gerrit-mcp"    }  }}

<project>/.claude/settings.local.json carries the project's environment; every env entry reaches the server process:

json
{  "env": {    "GERRIT_URL": "https://gerrit.example.com",    "GERRIT_USERNAME": "your-username",    "GERRIT_TOKEN": "your-http-credential",    "GERRIT_MCP_GROUPS": "read,comment",    "GERRIT_MCP_PROJECTS": "core,infra"  }}

Values shared by most projects can sit one layer down in ~/.claude/settings.json. Settings files merge, with .claude/settings.local.json over .claude/settings.json over ~/.claude/settings.json, so a project declares only its deltas. Anything no layer sets falls back to the server's own defaults: read-only, own changes.

The registration's env block stays empty for a reason. A variable named there shadows every settings layer, and references are no workaround: ${VAR} expands only from the shell environment that launched claude, never from settings files, and anything unresolved reaches the server as a literal string.

Other MCP clients inherit their launch environment the same way, so per-directory tooling such as direnv achieves the identical split without client support.

Capability groups

Capability is selected at startup via --groups as a comma-separated list. Groups are independent and combinable, with no privilege ladder: each write-capable group bundles the minimal change-read subset it needs to work on its own, and enabled groups union.

GroupTools
readsearch_changes, get_change, list_change_files, get_file_diff, get_change_comments
commentget_change, get_change_comments, post_comments
transitionget_change, set_vote, transition_change

Tools

  • search_changes: query changes with Gerrit's change query syntax, paginated.
  • get_change: one change in review-relevant detail: status, owner, labels with votes, current revision, messages.
  • list_change_files: files touched by a revision, with per-file change stats.
  • get_file_diff: the diff of one file in a revision.
  • get_change_comments: comment threads on a change, with resolution state and comment ids. Returns unresolved threads only by default; status=all fetches the full history, status=resolved the settled threads.
  • post_comments: publish a review in one call: optional top-level message plus inline, range, file-level, and reply comments. Replies anchor to comment ids from get_change_comments; resolved toggles the thread state.
  • set_vote: set a label vote (e.g. Code-Review) with an optional message; value 0 clears an own vote.
  • transition_change: move a change's state: submit, abandon, restore, wip, or ready, with an optional message (submit accepts none). Gerrit's refusal (a blocked submit, a restore of a merged change) is reported verbatim.

Review notifications

An opt-in push channel for review activity. The agent subscribes to a change with subscribe_change; from then on, new change messages, votes, inline comment threads, and status transitions arrive in the session on their own as review_activity blocks. The payload uses the same llmxml vocabulary the read tools emit and carries the activity whole, so nothing needs fetching afterwards. unsubscribe_change ends a subscription early. A merged or abandoned change ends its own subscription with a final notification that says so, and a change that becomes unreadable (deleted, or no longer visible to the account) does the same, with the reason spelled out.

Subscriptions are per-session and in-memory: they leave no trace on the Gerrit instance, end with the session, and after a server restart the agent subscribes again. With the feature off (the default) the server is byte-identical to its pre-feature self, with no extra tools or capabilities and no background polling.

Enabling takes both sides:

  1. Server side: pass --review-notifications=true (or its mirror). The server registers both subscription tools and polls Gerrit every --review-notifications-poll-interval (default 60s): one batched query per tick over all subscribed changes, with detail fetches only for changes that actually moved.
  2. Client side: delivery uses the Claude Code channels contract (research preview, Claude Code 2.1.80 or newer). For a server registered plainly under mcpServers, launch with claude --dangerously-load-development-channels server:<name>, where <name> is the registration key; it becomes the source attribute of the injected <channel> blocks. Allowlisted channel plugins load with claude --channels instead.

Research-preview caveats: organization policy can disable channels entirely; the flag syntax may change between Claude Code releases; and a client without channel support silently drops the events, in which case the server behaves exactly as if the feature were off, with no errors on either side.

Noise control is operator configuration. The server applies no heuristics of its own and filters nothing by message tag, because a bot's verdict is often exactly the outcome the agent is waiting for:

  • the authenticated account's own activity is skipped by default (--review-notifications-include-own keeps it);
  • --review-notifications-exclude-accounts silences accounts by username or numeric ID;
  • --review-notifications-exclude-patterns drops events whose message or comment text matches a regular expression; an invalid pattern fails startup with an error naming it.

Every flag has a GERRIT_MCP_* mirror that follows the same settings layering as the rest of the configuration (see Per-project configuration), so a project can enable notifications and pick exclusions in its own settings file.

Configuration reference

Behavior is configured by CLI flags, each mirrored by an environment variable so one configuration style works for binary and Docker invocations alike. Precedence: the flag wins over its mirror, and the mirror wins over the default.

FlagMirrorDefaultMeaning
--groupsGERRIT_MCP_GROUPSreadComma-separated capability groups: read, comment, transition
--projectsGERRIT_MCP_PROJECTS(empty)Project allowlist confining every operation, reads included
--own-changes-onlyGERRIT_MCP_OWN_CHANGES_ONLYtrueRefuse trail-leaving operations on changes not owned by the authenticated account
--include-toolsGERRIT_MCP_INCLUDE_TOOLS(empty)Keep only the listed tools from the group-resolved set
--exclude-toolsGERRIT_MCP_EXCLUDE_TOOLS(empty)Remove the listed tools from the group-resolved set
--review-notificationsGERRIT_MCP_REVIEW_NOTIFICATIONSfalseEnable review notifications
--review-notifications-poll-intervalGERRIT_MCP_REVIEW_NOTIFICATIONS_POLL_INTERVAL60sPoll cadence for subscribed changes, as a Go duration
--review-notifications-include-ownGERRIT_MCP_REVIEW_NOTIFICATIONS_INCLUDE_OWNfalseKeep the authenticated account's own activity in notifications
--review-notifications-exclude-accountsGERRIT_MCP_REVIEW_NOTIFICATIONS_EXCLUDE_ACCOUNTS(empty)Accounts (usernames or numeric IDs) whose activity never becomes a notification
--review-notifications-exclude-patternsGERRIT_MCP_REVIEW_NOTIFICATIONS_EXCLUDE_PATTERNS(empty)Comma-separated regular expressions; matching message or comment text never becomes a notification

Notes:

  • --own-changes-only takes an explicit boolean value: --own-changes-only=false. A bare flag without a value is a configuration error.
  • Project scoping (--projects) is enforced server-side: a project clause is injected into every change query regardless of what the agent composed, and direct operations on out-of-scope changes are refused.
  • Tool filters only narrow. --exclude-tools removes tools from what the groups resolved; --include-tools keeps only the listed subset of it. A tool outside the enabled groups can never be activated by a filter, and exclude wins over include. Filter entries naming no known tool fail startup, so misconfigurations surface immediately.
  • Configuration errors are aggregated: the server reports every problem at once, then exits non-zero.

Output format

Every tool responds in llmxml, an LLM-digestible subset of XML: line-structured, semantically tagged text meant to be read by a model. Attributes carry metadata; element bodies carry content:

<changes query="status:open owner:self" start="0" count="1" more="false"><change number="12345" project="core" branch="main" status="NEW" owner="Jane Doe (jdoe)" updated="2026-07-10T20:48:32Z">fix scanner initialization</change></changes>

There is no XML declaration, no namespaces, and no schema; nothing parses it back. If you need machine-readable Gerrit data, use Gerrit's REST API directly; this format is for model consumption.

License

MIT

來源:README.md,提交 9fe60e9

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.1.3最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Review 整合