Home / MCP / GitLab Code Review MCP Server
Provides an MCP server to analyze GitLab merge requests, view diffs, compare versions, and manage reviews via AI assistants.
Configuration
View docs{
"mcpServers": {
"gitlab_code_mcp": {
"command": "/path/to/your/gitlab-mcp-code-review/.venv/bin/python",
"args": [
"server.py",
"--transport",
"stdio"
],
"env": {
"GITLAB_TOKEN": "YOUR_TOKEN",
"GITLAB_HOST": "gitlab.com",
"GITLAB_API_VERSION": "v4",
"LOG_LEVEL": "INFO",
"DEBUG": "false",
"REQUEST_TIMEOUT": "30",
"MAX_RETRIES": "3",
"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"
}
}
}
}You can run a Python-based MCP server that connects an AI assistant to GitLab merge requests for full MR analysis, file diffs, and review actions. This MCP server lets you fetch merge request details, view file-level changes, compare versions, and manage approvals and comments from your AI assistant or client tools.
You will run a local MCP server that communicates with your AI assistant or client via stdio. This server exposes functions to fetch merge request details, retrieve diffs for whole MRs or specific files, compare branches or commits, and manage reviews by adding comments or changing approval status. To start, ensure the MCP server is running in a Python virtual environment and is connected to your client through a stdio transport. Your client will send requests that map to the server’s functions, and you will receive structured results you can present to users or use to generate automated guidance.
# Prerequisites
# - Python 3.10+ installed on your system
# - A GitLab Personal Access Token with API scope
# - Optional: Cursor IDE or Claude Desktop App for MCP integration
# 1. Clone or obtain the MCP server workspace
# (Use your existing path where the project resides)
# 2. Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Run the MCP server (example start command shown later in the config)Once dependencies are installed, you will run the server using a Python command configured for your environment. The package expects a Python interpreter inside a virtual environment and a server script that communicates over stdio to your MCP client.
The MCP server provides a stdio-based transport configuration you can use with an MCP client. You run the server from your local workspace and point your client to the same workspace paths. The configuration shown below uses a Python virtual environment and the server script to start the MCP via stdio.
{
"mcpServers": {
"gitlab_code_mcp": {
"command": "/path/to/your/gitlab-mcp-code-review/.venv/bin/python",
"args": [
"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
}
}
}Environment variables shown here control where Python looks for modules, which virtual environment to use, and which executables are in your PATH. If you encounter connection or permission issues, verify the following: the Python token/config is accessible, the virtual environment is activated, and the server script path is correct. Set the logging level to DEBUG to gather more details during troubleshooting.
Get complete information about a merge request including details such as diffs, commits, and comments.
Get diffs for a specific merge request or a file within a merge request.
Get diff information for a specific commit within a project.
Compare different branches, tags, or commits to surface changes.
Add a comment to a merge request to provide feedback or notes.
Approve a merge request to indicate readiness for merge.
Remove an approval on a merge request.
Get a list of merge requests for a specific project.