mcp-gerrit-code-review

mcp-gerrit-code-review

MCP Server providing AI agents with tooling for Gerrit code review workflows via stdio transport.

Category
访问服务器

README

MCP Gerrit Code Review

npm TypeScript License: MIT

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 ~/.netrc fallback (HTTP mode)
  • SSH key auth with env vars or ~/.ssh/id_rsa fallback (SSH mode)
  • TypeScript strict mode with Zod input validation
  • ESM modules with stdio transport

Installation

Option 1: Install from npm (Recommended)

npx mcp-gerrit-code-review

Or install globally:

npm install -g mcp-gerrit-code-review

Option 2: Build from source

git clone https://github.com/coveyjorjet/mcp-gerrit-code-review.git
cd mcp-gerrit-code-review
npm install && npm run build

Configuration

HTTP Transport (Default)

Set via environment variables:

export GERRIT_URL=https://gerrit.example.com
export GERRIT_USERNAME=your-username
export GERRIT_PASSWORD=your-http-password

Or use ~/.netrc:

machine gerrit.example.com
  login your-username
  password your-http-password

SSH 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  # optional

Or use SSH URL format in GERRIT_URL:

export GERRIT_TRANSPORT=ssh
export GERRIT_URL=ssh://your-username@gerrit.example.com:29418

SSH 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 query_changes, get_change_details, list_change_files, get_file_diff, get_commit_message, post_review, post_review_comment, list_change_comments, submit_change, abandon_change, restore_change, list_reviewers, add_reviewer Code review operations
Accounts get_account, query_accounts User account management (HTTP only)
Projects list_projects Project discovery
Server get_server_version, get_server_info 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 parsing

Development

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选