- Home
- MCP servers
- GitLab MCP for Code Review
GitLab MCP for Code Review
- python
41
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"mehmetakinn-gitlab-mcp-code-review": {
"command": "python",
"args": [
"server.py",
"--transport",
"stdio"
],
"env": {
"PATH": "<venv-path>:/usr/local/bin:/usr/bin:/bin",
"DEBUG": "false",
"LOG_LEVEL": "INFO",
"PYTHONPATH": "<path-to-your-mcp-root>",
"GITLAB_HOST": "gitlab.com",
"MAX_RETRIES": "3",
"VIRTUAL_ENV": "<path-to-your-venv>",
"GITLAB_TOKEN": "glpat-abcdefghijklmnopqrstuvwxyz",
"REQUEST_TIMEOUT": "30",
"GITLAB_API_VERSION": "v4"
}
}
}
}You run a Python-based MCP server that connects AI assistants to GitLab merge requests. It fetches complete MR data, diffs, commits, and comments, and lets you add comments or approvals, enabling automated code review workflows within GitLab.
How to use
You will run the MCP server locally and connect your MCP client (such as Cursor IDE or Claude Desktop App) to it. Once linked, you can request full merge request analyses, file-specific diffs, and version comparisons, then perform review actions like commenting or approving directly from your AI assistant.
How to install
Prerequisites: Python 3.10+ and a GitLab personal access token with API scope.
-
Create a virtual environment and activate it.
-
Install dependencies from the requirements file.
-
Prepare a configuration file with your GitLab settings (the example options below show the typical variables you will use). They include your GitLab token, host, API version, and logging preference.
-
Run the MCP server using the standard Python command sequence described in the configuration steps.
Configuration and usage notes
Environment variables you will configure in your environment file include the token, host, API version, and logging controls. The following options are commonly used:
GITLAB_TOKEN: Your GitLab personal access token with API scope
GITLAB_HOST: GitLab instance hostname (default: gitlab.com)
GITLAB_API_VERSION: API version to use (default: v4)
LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
DEBUG, REQUEST_TIMEOUT, MAX_RETRIES: Optional controls for debugging and reliability
Troubleshooting
If you encounter issues, verify your GitLab token permissions, review your environment variable values, and confirm the MCP server path and Python virtual environment are correct. Increase logging by setting LOG_LEVEL to DEBUG for more details.
Available tools
fetch_merge_request
Get complete information about a merge request including details, diffs, commits, and comments.
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.