Home / MCP / GitLab MCP for Code Review MCP Server
An MCP server that integrates AI assistants with GitLab merge requests for full MR analysis and review actions.
Configuration
View docs{
"mcpServers": {
"gitlab_mcp": {
"command": "python",
"args": [
"server.py",
"--transport",
"stdio"
],
"env": {
"GITLAB_TOKEN": "glpat-abcdefghijklmnopqrstuvwxyz",
"GITLAB_HOST": "gitlab.com",
"GITLAB_API_VERSION": "v4",
"LOG_LEVEL": "INFO",
"DEBUG": "false",
"REQUEST_TIMEOUT": "30",
"MAX_RETRIES": "3",
"PYTHONPATH": "<path-to-your-mcp-root>",
"VIRTUAL_ENV": "<path-to-your-venv>",
"PATH": "<venv-path>:/usr/local/bin:/usr/bin:/bin"
}
}
}
}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.
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.
Prerequisites: Python 3.10+ and a GitLab personal access token with API scope.
1. Create a virtual environment and activate it.
2. Install dependencies from the requirements file.
3. 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.
4. Run the MCP server using the standard Python command sequence described in the configuration steps.
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
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.
Get complete information about a merge request including details, diffs, commits, and comments.
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.