go-gerrit-mcp
An MCP server that exposes Gerrit code review operations as capability-gated tools, enabling AI agents to search and read changes, publish comments, vote, and manage change state, with write capabilities as explicit opt-in.
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
readgroup 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:
# agent may comment and vote on anyone's changes, but only within two projects
go-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:
# macOS on Apple silicon; substitute <os>_<arch> from: linux, darwin, windows x amd64, arm64
curl -Lo /usr/local/bin/go-gerrit-mcp \
https://github.com/GaijinEntertainment/go-gerrit-mcp/releases/latest/download/go-gerrit-mcp_darwin_arm64
chmod +x /usr/local/bin/go-gerrit-mcp
Docker:
docker pull ghcr.io/gaijinentertainment/go-gerrit-mcp:latest
go install:
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:
| Variable | Meaning |
|---|---|
GERRIT_URL |
Base URL of the Gerrit instance |
GERRIT_USERNAME |
Account username for HTTP Basic authentication |
GERRIT_TOKEN |
HTTP 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
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)
{
"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
{
"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:
{
"mcpServers": {
"gerrit": {
"command": "go-gerrit-mcp"
}
}
}
<project>/.claude/settings.local.json carries the project's environment; every env entry reaches the server
process:
{
"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.
| Group | Tools |
|---|---|
read |
search_changes, get_change, list_change_files, get_file_diff, get_change_comments |
comment |
get_change, get_change_comments, post_comments |
transition |
get_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=allfetches the full history,status=resolvedthe 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 fromget_change_comments;resolvedtoggles the thread state.set_vote: set a label vote (e.g.Code-Review) with an optional message; value0clears an own vote.transition_change: move a change's state:submit,abandon,restore,wip, orready, 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:
- Server side: pass
--review-notifications=true(or its mirror). The server registers both subscription tools and polls Gerrit every--review-notifications-poll-interval(default60s): one batched query per tick over all subscribed changes, with detail fetches only for changes that actually moved. - 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 withclaude --dangerously-load-development-channels server:<name>, where<name>is the registration key; it becomes thesourceattribute of the injected<channel>blocks. Allowlisted channel plugins load withclaude --channelsinstead.
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-ownkeeps it); --review-notifications-exclude-accountssilences accounts by username or numeric ID;--review-notifications-exclude-patternsdrops 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.
| Flag | Mirror | Default | Meaning |
|---|---|---|---|
--groups |
GERRIT_MCP_GROUPS |
read |
Comma-separated capability groups: read, comment, transition |
--projects |
GERRIT_MCP_PROJECTS |
(empty) | Project allowlist confining every operation, reads included |
--own-changes-only |
GERRIT_MCP_OWN_CHANGES_ONLY |
true |
Refuse trail-leaving operations on changes not owned by the authenticated account |
--include-tools |
GERRIT_MCP_INCLUDE_TOOLS |
(empty) | Keep only the listed tools from the group-resolved set |
--exclude-tools |
GERRIT_MCP_EXCLUDE_TOOLS |
(empty) | Remove the listed tools from the group-resolved set |
--review-notifications |
GERRIT_MCP_REVIEW_NOTIFICATIONS |
false |
Enable review notifications |
--review-notifications-poll-interval |
GERRIT_MCP_REVIEW_NOTIFICATIONS_POLL_INTERVAL |
60s |
Poll cadence for subscribed changes, as a Go duration |
--review-notifications-include-own |
GERRIT_MCP_REVIEW_NOTIFICATIONS_INCLUDE_OWN |
false |
Keep the authenticated account's own activity in notifications |
--review-notifications-exclude-accounts |
GERRIT_MCP_REVIEW_NOTIFICATIONS_EXCLUDE_ACCOUNTS |
(empty) | Accounts (usernames or numeric IDs) whose activity never becomes a notification |
--review-notifications-exclude-patterns |
GERRIT_MCP_REVIEW_NOTIFICATIONS_EXCLUDE_PATTERNS |
(empty) | Comma-separated regular expressions; matching message or comment text never becomes a notification |
Notes:
--own-changes-onlytakes 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-toolsremoves tools from what the groups resolved;--include-toolskeeps 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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。