- Explore MCP Servers
- gerrit-mcp
Gerrit Mcp
What is Gerrit Mcp
gerrit-mcp is a Model Context Protocol (MCP) server implementation that integrates Gerrit code reviews with AI-powered IDEs, enabling automated code reviews by connecting your Gerrit instance with AI capabilities.
Use cases
Use cases include automating code reviews, generating draft comments based on AI analysis, fetching detailed change information for review, and facilitating collaborative coding efforts in teams.
How to use
To use gerrit-mcp, install it via pip from GitHub or clone the repository for development. Set up a virtual environment and install the package in development mode. Configure the environment variables as needed.
Key features
Key features include seamless integration with AI-powered IDEs, fetching commit information, managing draft comments, applying Code-Review labels, and authenticated interaction with the Gerrit REST API.
Where to use
gerrit-mcp is suitable for software development environments where code reviews are essential, particularly in teams using Gerrit for version control and seeking to enhance their review process with AI.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Gerrit Mcp
gerrit-mcp is a Model Context Protocol (MCP) server implementation that integrates Gerrit code reviews with AI-powered IDEs, enabling automated code reviews by connecting your Gerrit instance with AI capabilities.
Use cases
Use cases include automating code reviews, generating draft comments based on AI analysis, fetching detailed change information for review, and facilitating collaborative coding efforts in teams.
How to use
To use gerrit-mcp, install it via pip from GitHub or clone the repository for development. Set up a virtual environment and install the package in development mode. Configure the environment variables as needed.
Key features
Key features include seamless integration with AI-powered IDEs, fetching commit information, managing draft comments, applying Code-Review labels, and authenticated interaction with the Gerrit REST API.
Where to use
gerrit-mcp is suitable for software development environments where code reviews are essential, particularly in teams using Gerrit for version control and seeking to enhance their review process with AI.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Gerrit AI Review MCP
A Model Context Protocol (MCP) server implementation that integrates Gerrit code reviews with AI-powered IDEs like Cursor. This server enables automated code reviews by connecting your Gerrit instance with AI capabilities through the MCP protocol.
Features
-
MCP Server Implementation:
- Built using the MCP Python SDK
- Exposes Gerrit functionality through MCP tools
- Seamless integration with AI-powered IDEs
-
Gerrit Integration:
- Fetch commit information and change details
- Create and manage draft comments
- Support for line-specific and global comments
- Apply Code-Review labels (-1 or -2)
- Authenticated Gerrit REST API interaction
-
Available Tools:
gerrit_get_commit_info: Fetch basic commit informationgerrit_get_change_detail: Retrieve detailed change informationgerrit_get_commit_message: Get commit messagesgerrit_get_related_changes: Find related changesgerrit_get_file_list: List modified filesgerrit_get_file_diff: Get file-specific diffsgerrit_create_draft_comment: Create draft commentsgerrit_set_review: Submit reviews with labels
Installation
You can install this package directly from GitHub using pip:
pipx install git+https://github.com/siarhei-belavus/gerrit-mcp.git
Or, for development:
- Clone the repository:
git clone [email protected]:siarhei-belavus/gerrit-mcp.git
cd gerrit-mcp
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install in development mode:
pip install -e .
Configuration Options
Environment Variables
The repository includes an .env.template file that you can copy and modify:
cp .env.template .env
Then edit the .env file with your Gerrit credentials:
GERRIT_URL=your_gerrit_url GERRIT_USERNAME=your_username GERRIT_API_TOKEN=your_api_token
Command-Line Arguments
Alternatively, you can use command-line arguments when running the server:
GERRIT_URL=your_gerrit_url GERRIT_USERNAME=your_username GERRIT_API_TOKEN=your_api_token
Project Structure
The project follows a modular architecture:
src/ ├── gerrit/ # Gerrit API client │ ├── api.py # API request functions │ ├── auth.py # Authentication utilities │ └── models.py # Data models ├── mcp/ # MCP server implementation │ ├── server.py # Server setup │ └── tools/ # MCP tool implementations │ ├── commit_tools.py # Commit-related tools │ ├── file_tools.py # File-related tools │ └── review_tools.py # Review and comment tools └── utils/ # Utility functions ├── error_handling.py # Error handling utilities └── logging.py # Logging utilities
Cursor IDE Integration
To integrate this MCP server with Cursor IDE:
- Install the package:
pipx install git+https://github.com/siarhei-belavus/gerrit-mcp.git
- Configure the MCP server in Cursor by creating/editing
~/.cursor/mcp.json:
{
"mcpServers": {
"gerrit-mcp": {
"command": "gerrit-mcp",
"env": {
"GERRIT_URL": "your_gerrit_url",
"GERRIT_USERNAME": "your_username",
"GERRIT_API_TOKEN": "your_api_token"
}
}
}
}
Alternative Configuration with Command Arguments
If you prefer to use command-line arguments instead of environment variables:
{
"mcpServers": {
"gerrit-mcp": {
"command": "gerrit-mcp --gerrit_url your_gerrit_url --username your_username --api_token your_api_token",
"env": {}
}
}
}
Using environment variables is generally preferred for credentials since they:
- Don’t appear in process listings (like when running
ps aux) - Aren’t stored in command history
- Are easier to manage with credential management systems
You can also use project-specific configuration by placing the mcp.json file in your project’s .cursor directory.
For development from source, use the full path to the script:
{
"mcpServers": {
"gerrit-mcp": {
"command": "/absolute/path/to/gerrit-mcp/gerrit_mcp.sh",
"env": {}
}
}
}
Usage
- If installed via pip, run:
gerrit-mcp
Or if running from source:
python src/mmcp/server.py
Command line options:
--host HOST Host to bind the server to (default: 127.0.0.1) --port PORT Port to bind the server to (default: 5678) --debug Enable debug logging --log-file LOG_FILE Path to log file (default: logs to stdout) # Authentication options (when not using environment variables) --gerrit_url URL Gerrit server URL --username USERNAME Gerrit username --api_token TOKEN Gerrit API token or password For complete usage information, run: gerrit-mcp --help
- In Cursor IDE:
- Open a conversation about a Gerrit review
- Paste a Gerrit change URL
- Ask Cursor to review the changes using the available tools
- Approve comments to be posted back to Gerrit
Example prompts:
- “Review this Gerrit change for issues”
- “Create draft comments for the problematic areas”
- “Submit the review with appropriate labels”
Example Conversation
Here’s how a typical conversation might look in Cursor:
You: Review this Gerrit commit https://gerrit.example.com/c/project/+/12345 Agent: I'll review this Gerrit commit for you. [Agent is using Gerrit MCP tools...] Agent: I've completed my review of the commit. Here are the issues I found: 1. In file.py: - Line 24: This loop has O(n²) complexity which could be optimized - Line 45: Unused variable 'result' 2. In another_file.js: - Line 12: Missing error handling for the async operation Would you like me to create draft comments for these issues in Gerrit? You: Yes, please create the comments Agent: Creating draft comments... Comments have been created in Gerrit for the issues found. Would you like me to apply a Code-Review label to this change? You: Apply -1 since there are issues that need to be fixed Agent: Applied Code-Review: -1 to the change.
Development
Prerequisites
- Python 3.10 or higher
- Git
- Access to a Gerrit instance
Running Tests
For unit tests (which can run without a Gerrit instance):
# Using the test runner script
python run_tests.py
# Or directly with pytest
python -m pytest tests/unit -v
For integration tests (requires connection to a Gerrit instance):
python tests/integration_test.py
Setting Up Development Environment
# Install development dependencies
pip install -r requirements-dev.txt
# Install the package in development mode
pip install -e .
Continuous Integration
This repository uses GitHub Actions for continuous integration, which automatically:
- Lints the code with Ruff
- Runs unit tests with pytest
- Builds the package
The workflow runs on every push to the main branch and on pull requests.
Building from Source
- Install build requirements:
pip install build
- Build the package:
python -m build
This will create distribution files in the dist/ directory.
Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










