GitLab Code Review MCP
Provides comprehensive GitLab integration for code review workflows, including fetching merge request details and diffs, comparing branches/commits, managing comments, and approving/unapproving merge requests through the GitLab API.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GitLab Code Review MCPreview merge request #5 in project 123 and suggest improvements"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Related MCP server: GitLab MCP Code Review
Installation
Prerequisites
Python 3.10+
GitLab personal access token with API scope (read_api, api)
Cursor IDE or Claude Desktop App for MCP integration
Quick Start
Clone this repository:
git clone https://github.com/lininn/gitlab-code-review-mcp.git
cd gitlab-mcp-code-reviewCreate and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtCreate a
.envfile with your GitLab configuration (see.env.examplefor all options):
# Required
GITLAB_TOKEN=your_personal_access_token_here
# Optional settings
GITLAB_HOST=gitlab.com
GITLAB_API_VERSION=v4
LOG_LEVEL=INFOConfiguration 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.
Claude Desktop App Integration
To use this MCP with the Claude Desktop App:
Open the Claude Desktop App
Go to Settings → Advanced → MCP Configuration
Add the following configuration:
{
"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 |
| Get complete information about a merge request |
| Get diffs for a specific merge request |
| Get diff information for a specific commit |
| Compare different branches, tags, or commits |
| Add a comment to a merge request |
| Approve a merge request |
| Unapprove a merge request |
| 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
.envfile settingsEnsure your MCP configuration paths are correct
Test connection with:
curl -H "Private-Token: your-token" https://gitlab.com/api/v4/projectsSet 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.
Code Review Standards
This project follows strict code review standards to ensure quality and maintainability:
📋 Code Review Guidelines: This project follows a strict set of code review guidelines to ensure quality and consistency. For detailed information on the review process, standards, and best practices, please see the Code Review Guidelines.
✅ Review Checklist: All pull requests should be checked against the PULL_REQUEST_CHECKLIST.md before submission.
🔄 CI/CD Pipeline: We use GitLab CI for automated quality checks. Ensure all pipeline checks pass before requesting a review.
📝 Templates: Please use the provided merge request and issue templates to ensure all necessary information is included.
Quick Start for Contributors
Read the Code Review Guidelines
Use the appropriate MR template when creating pull requests
Ensure all CI checks pass before requesting review
Address all reviewer feedback promptly
License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceConnects AI assistants to GitLab, allowing users to manage merge requests, view reviews, and interact with discussions through natural language queries.Last updated1225MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to review GitLab merge requests by fetching changes, analyzing diffs, adding comments, and managing approvals through the GitLab API. Supports complete merge request analysis, file-specific reviews, and version comparisons.Last updated124MIT
- Alicense-qualityDmaintenanceEnables AI agents to interact with GitLab repositories, manage merge requests, review code diffs, post comments, and handle issues directly through natural language.Last updated56MIT
- FlicenseAqualityCmaintenanceConnects AI assistants to GitLab to interact with merge requests, reviews, discussions, pipelines, and test results through natural language queries. Supports viewing MR details, responding to comments, checking test summaries, and analyzing job logs.Last updated122
Related MCP Connectors
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analy…
A Model Context Protocol (MCP) application for automated GitHub PR analysis and issue management.…
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/lininn/gitlab-code-review-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server