
GitLab MCP for Code Review
An MCP server that integrates AI assistants like Claude with GitLab's merge requests, allowing them to review code changes, add comments, and approve/unapprove merge requests directly through the GitLab API.
README
GitLab MCP for Code Review
This project is forked from cayirtepeomer/gerrit-code-review-mcp and adapted for GitLab integration.
An MCP (Model Context Protocol) server for integrating AI assistants like Claude with GitLab's merge requests. This allows AI assistants to review code changes directly through the GitLab API.
Features
- Complete Merge Request Analysis: Fetch full details about merge requests including diffs, commits, and comments
- File-Specific Diffs: Analyze changes to specific files within merge requests
- Version Comparison: Compare different branches, tags, or commits
- Review Management: Add comments, approve, or unapprove merge requests
- Project Overview: Get lists of all merge requests in a project
Installation
Prerequisites
- Python 3.10+
- GitLab personal access token with API scope (read_api, api)
- Cursor IDE for full MCP integration
Quick Start
- Clone this repository:
git clone https://github.com/yourusername/gitlab-mcp-code-review.git
cd gitlab-mcp-code-review
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file with your GitLab configuration (see.env.example
for all options):
# Required
GITLAB_TOKEN=your_personal_access_token_here
# Optional settings
GITLAB_HOST=gitlab.com
GITLAB_API_VERSION=v4
LOG_LEVEL=INFO
Configuration Options
The following environment variables can be configured in your .env
file:
Variable | Required | Default | Description |
---|---|---|---|
GITLAB_TOKEN | Yes | - | Your GitLab personal access token |
GITLAB_HOST | No | gitlab.com | GitLab instance hostname |
GITLAB_API_VERSION | No | v4 | GitLab API version to use |
LOG_LEVEL | No | INFO | Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
DEBUG | No | false | Enable debug mode |
REQUEST_TIMEOUT | No | 30 | API request timeout in seconds |
MAX_RETRIES | No | 3 | Maximum retry attempts for failed requests |
Cursor IDE Integration
To use this MCP with Cursor IDE, add this configuration to your ~/.cursor/mcp.json
file:
{
"mcpServers": {
"gitlab-mcp-code-review": {
"command": "/path/to/your/gitlab-mcp-code-review/.venv/bin/python",
"args": [
"/path/to/your/gitlab-mcp-code-review/server.py",
"--transport",
"stdio"
],
"cwd": "/path/to/your/gitlab-mcp-code-review",
"env": {
"PYTHONPATH": "/path/to/your/gitlab-mcp-code-review",
"VIRTUAL_ENV": "/path/to/your/gitlab-mcp-code-review/.venv",
"PATH": "/path/to/your/gitlab-mcp-code-review/.venv/bin:/usr/local/bin:/usr/bin:/bin"
},
"stdio": true
}
}
}
Replace /path/to/your/gitlab-mcp-code-review
with the actual path to your cloned repository.
Available Tools
The MCP server provides the following tools for interacting with GitLab:
Tool | Description |
---|---|
fetch_merge_request |
Get complete information about a merge request |
fetch_merge_request_diff |
Get diffs for a specific merge request |
fetch_commit_diff |
Get diff information for a specific commit |
compare_versions |
Compare different branches, tags, or commits |
add_merge_request_comment |
Add a comment to a merge request |
approve_merge_request |
Approve a merge request |
unapprove_merge_request |
Unapprove a merge request |
get_project_merge_requests |
Get a list of merge requests for a project |
Usage Examples
Fetch a Merge Request
# Get details of merge request #5 in project with ID 123
mr = fetch_merge_request("123", "5")
View Specific File Changes
# Get diff for a specific file in a merge request
file_diff = fetch_merge_request_diff("123", "5", "path/to/file.js")
Compare Branches
# Compare develop branch with master branch
diff = compare_versions("123", "develop", "master")
Add a Comment to a Merge Request
# Add a comment to a merge request
comment = add_merge_request_comment("123", "5", "This code looks good!")
Approve a Merge Request
# Approve a merge request and set required approvals to 2
approval = approve_merge_request("123", "5", approvals_required=2)
Troubleshooting
If you encounter issues:
- Verify your GitLab token has the appropriate permissions (api, read_api)
- Check your
.env
file settings - Ensure your MCP configuration paths are correct
- Test connection with:
curl -H "Private-Token: your-token" https://gitlab.com/api/v4/projects
- Set LOG_LEVEL=DEBUG in your .env file for more detailed logging
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
See the CONTRIBUTING.md file for more details on the development process.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.