mcp-gerrit-code-review
Provides tools for interacting with Gerrit code review system, enabling AI agents to manage changes (query, review, submit, abandon, restore), accounts, projects, and server information.
MCP Gerrit Code Review
MCP Server providing AI agents with tooling for Gerrit code review workflows via stdio transport.
Features
19 tools across 4 categories: Changes, Accounts, Projects, Server
Dual transport: HTTP (REST API) or SSH (gerrit CLI commands)
Dynamic tool registration: Tools auto-enable based on server capabilities
Basic Auth with env vars or
~/.netrcfallback (HTTP mode)SSH key auth with env vars or
~/.ssh/id_rsafallback (SSH mode)TypeScript strict mode with Zod input validation
ESM modules with stdio transport
Related MCP server: Gerrit MCP Server
Installation
Option 1: Install from npm (Recommended)
npx mcp-gerrit-code-reviewOr install globally:
npm install -g mcp-gerrit-code-reviewOption 2: Build from source
git clone https://github.com/coveyjorjet/mcp-gerrit-code-review.git
cd mcp-gerrit-code-review
npm install && npm run buildConfiguration
HTTP Transport (Default)
Set via environment variables:
export GERRIT_URL=https://gerrit.example.com
export GERRIT_USERNAME=your-username
export GERRIT_PASSWORD=your-http-passwordOr use ~/.netrc:
machine gerrit.example.com
login your-username
password your-http-passwordSSH Transport
Set transport mode and SSH connection details:
export GERRIT_TRANSPORT=ssh
export GERRIT_SSH_HOST=gerrit.example.com
export GERRIT_SSH_USER=your-username
export GERRIT_SSH_PORT=29418 # optional, defaults to 29418
export GERRIT_SSH_KEY=~/.ssh/id_rsa # optional, defaults to ~/.ssh/id_rsa
export GERRIT_SSH_KEY_PASSPHRASE=your-passphrase # optionalOr use SSH URL format in GERRIT_URL:
export GERRIT_TRANSPORT=ssh
export GERRIT_URL=ssh://your-username@gerrit.example.com:29418SSH credentials are resolved from ~/.netrc for username if not specified.
Usage
Using with OpenCode
Add to your opencode.json or opencode.jsonc:
Using npm package (HTTP)
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"mcp-gerrit-code-review": {
"type": "local",
"command": ["npx", "-y", "mcp-gerrit-code-review"],
"enabled": true,
"environment": {
"GERRIT_URL": "https://gerrit.example.com",
"GERRIT_USERNAME": "your-username",
"GERRIT_PASSWORD": "your-http-password"
}
}
}
}Using npm package (SSH)
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"mcp-gerrit-code-review": {
"type": "local",
"command": ["npx", "-y", "mcp-gerrit-code-review"],
"enabled": true,
"environment": {
"GERRIT_TRANSPORT": "ssh",
"GERRIT_SSH_HOST": "gerrit.example.com",
"GERRIT_SSH_USER": "your-username",
"GERRIT_SSH_KEY": "/path/to/private/key"
}
}
}
}Using local build
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"mcp-gerrit-code-review": {
"type": "local",
"command": ["node", "/path/to/mcp-gerrit-code-review/dist/index.js"],
"enabled": true,
"environment": {
"GERRIT_URL": "https://gerrit.example.com",
"GERRIT_USERNAME": "your-username",
"GERRIT_PASSWORD": "your-http-password"
}
}
}
}Other MCP Clients
Add to your MCP client configuration:
Using npm package (HTTP)
{
"mcpServers": {
"mcp-gerrit-code-review": {
"command": "npx",
"args": ["-y", "mcp-gerrit-code-review"],
"env": {
"GERRIT_URL": "https://gerrit.example.com",
"GERRIT_USERNAME": "your-username",
"GERRIT_PASSWORD": "your-http-password"
}
}
}
}Using npm package (SSH)
{
"mcpServers": {
"mcp-gerrit-code-review": {
"command": "npx",
"args": ["-y", "mcp-gerrit-code-review"],
"env": {
"GERRIT_TRANSPORT": "ssh",
"GERRIT_SSH_HOST": "gerrit.example.com",
"GERRIT_SSH_USER": "your-username",
"GERRIT_SSH_KEY": "/path/to/private/key"
}
}
}
}Using local build
{
"mcpServers": {
"mcp-gerrit-code-review": {
"command": "node",
"args": ["dist/index.js"],
"env": {
"GERRIT_URL": "https://gerrit.example.com",
"GERRIT_USERNAME": "your-username",
"GERRIT_PASSWORD": "your-http-password"
}
}
}
}Tools
Category | Tools | Description |
Changes |
| Code review operations |
Accounts |
| User account management (HTTP only) |
Projects |
| Project discovery |
Server |
| Server metadata (info: HTTP only) |
⚠️ Mutation tools (
post_review,post_review_comment,submit_change,abandon_change,restore_change,add_reviewer) modify Gerrit state — confirm with user before calling.
📝 Note: Available tools depend on transport mode and Gerrit server capabilities. Tools are dynamically registered at startup based on what the server supports.
Architecture
src/
├── index.ts # Entry point, MCP server setup
├── gerrit/
│ ├── client.ts # Gerrit API wrapper with HTTP/SSH transport
│ └── types.ts # TypeScript interfaces
├── tools/
│ ├── changes.ts # 13 change-related tools
│ ├── accounts.ts # 2 account tools (HTTP only)
│ ├── projects.ts # 1 project tool
│ └── server.ts # 2 server tools
└── utils/
└── parsing.ts # Credential resolution, SSH config parsingDevelopment
npm run dev # Watch mode rebuild
npm test # Run tests once
npm run test:watch # Watch mode tests
npm run lint # Type check (tsc --noEmit)License
MIT
Available Tools
18 toolsabandon_changeA
Abandon a Gerrit change. The change will no longer be considered for submission. Provide a reason message. This is a mutation — use intentionally and confirm with the user before calling.
Inputs: change_id (required), message.
add_reviewerA
Add a reviewer to a Gerrit change. Accepts account ID, username, email address, or group name. The reviewer will be notified. This is a mutation — use intentionally.
Inputs: reviewer (required), change_id (required).
get_accountA
Get details of a specific Gerrit account. Use 'self' to get the currently authenticated user's account info.
Inputs: account_id (required).
get_change_detailsA
Get detailed information about a specific Gerrit change. Returns full change metadata including owner, labels, messages, revisions, and reviewers.
Inputs: change_id (required), options.
get_commit_messageA
Get the full commit message for a revision of a Gerrit change. Includes subject, body, author, committer, and parent commits.
Inputs: change_id (required), revision_id.
get_file_diffA
Get the diff of a specific file in a Gerrit change. Returns the unified diff content including added, removed, and modified lines with context.
Inputs: change_id (required), file_path (required), revision_id.
get_server_infoA
Get Gerrit server configuration info. Returns server capabilities, authentication methods, change settings, download schemes, and plugin info.
Inputs: no named parameters.
get_server_versionA
Get the Gerrit server version string. Returns the version of the connected Gerrit instance.
Inputs: no named parameters.
list_change_commentsA
List all comments on a Gerrit change. Returns inline comments (with file path, line, and range) and file-level comments. Includes unresolved status and reply chains.
Inputs: change_id (required).
list_change_filesA
List files modified in a Gerrit change. Returns file paths with status (A=Added, D=Deleted, R=Renamed, W=Rewritten, M=Modified), size, and line counts.
Inputs: change_id (required), revision_id.
list_projectsA
List Gerrit projects accessible to the current user. Can filter by prefix and optionally include descriptions.
Inputs: limit, prefix, description.
list_reviewersA
List all reviewers of a Gerrit change. Returns reviewers, CC'd users, and removed reviewers along with their approval status.
Inputs: change_id (required).
post_reviewA
Post a review on a Gerrit change. Use this to vote on labels (e.g. Code-Review: +1), leave a cover message, mark as ready, or mark as work-in-progress. This is a mutation — use intentionally.
Inputs: change_id (required), tag, ready, labels, +3 more.
post_review_commentA
Post an inline comment on a specific file/line in a Gerrit change. Use this for line-by-line code review comments. Can reply to existing comments. This is a mutation — use intentionally.
Inputs: path (required), message (required), change_id (required), line, +3 more.
query_accountsA
Search for Gerrit accounts by name, username, or email. Useful for finding reviewers or looking up account details.
Inputs: query (required), limit.
query_changesA
Query Gerrit changes using Gerrit's query syntax. Returns a list of changes matching the query. Common queries: 'status:open', 'status:merged', 'project:myproject', 'owner:self', 'reviewer:self', 'is:watched'.
Inputs: limit, query, start, options.
restore_changeA
Restore an abandoned Gerrit change back to active status. This is a mutation — use intentionally.
Inputs: change_id (required).
submit_changeA
Submit a Gerrit change for merging. The change must be ready to submit (all required labels approved, no merge conflicts). This is a mutation — use intentionally and confirm with the user before calling.
Inputs: change_id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Each tool targets a distinct resource and action: account queries, project listing, change lifecycle, diff retrieval, review posting, and comment management. Even within the change-related tools, each one covers a separate aspect (details, files, diffs, commit message, comments, reviewers) with no meaningful overlap.
All tool names follow a consistent verb_noun pattern in lower_snake_case, such as list_*, get_*, query_*, post_*, add_*, and *_change. The verbs are consistently used to differentiate read vs. mutation operations without mixing conventions.
With 18 tools, the server is slightly above the typical 3-15 range but each tool earns its place for a comprehensive Gerrit integration. The count feels justified given the breadth of code review workflows, though it is a bit heavy compared to leaner MCP servers.
The tool set covers the full Gerrit code review lifecycle: querying changes, inspecting diffs and files, managing reviewers, posting reviews and comments, and executing state transitions (submit, abandon, restore). There are no obvious dead ends for common review tasks, and the lack of a 'create change' tool is appropriate since Gerrit changes are created via git push.
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides integration with Gerrit code review system, allowing AI assistants to fetch change details and compare patchset differences for code reviews.38MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables language models to query and manage Gerrit code reviews via the REST API.78 PyPI1Apache 2.0
- AlicenseBqualityDmaintenanceLocal MCP server providing project cognition capabilities for AI coding agents, including context packs, impact analysis, and git diff review through stdio communication.103MIT
- FlicenseNot gradedqualityBmaintenanceMCP server for AI DevTool workflow, exposing tools and resources for code review, repository chat, and repository operations.1-