The GitLab MCP Server allows you to interact with your GitLab projects directly through AI assistants. Connect your assistant to GitLab and perform tasks like viewing merge requests, checking reviews, and responding to discussions—all through natural language commands.
Clone and install the server:
git clone https://github.com/amirsina-mandegari/gitlab-mcp-server.git
cd gitlab-mcp-server
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
chmod +x run-mcp.sh
Create a GitLab access token:
read_api scopeConfigure your project:
Create a gitlab-mcp.env file in your project directory with:
GITLAB_PROJECT_ID=12345
GITLAB_ACCESS_TOKEN=glpat-xxxxxxxxxxxxxxxxxxxx
GITLAB_URL=https://gitlab.com
Connect to your AI assistant:
Create a .cursor/mcp.json file in your project:
{
"mcpServers": {
"gitlab-mcp": {
"command": "/path/to/gitlab-mcp-server/run-mcp.sh",
"cwd": "/path/to/your-project"
}
}
}
Restart your AI assistant to establish the connection
Once connected, you can use natural language to interact with GitLab:
List open merge requestsShow me details for merge request 456Get reviews and discussions for MR #123Find merge requests for the feature/auth-improvements branchShow me closed merge requests targeting mainThe server allows full interaction with merge request discussions:
View reviews and discussions:
Use this to get discussion IDs which you'll need for replies:
Show me reviews for MR #123
Reply to discussions:
Once you have the discussion ID, you can reply:
Reply to discussion abc123 in MR #456 with 'I'll fix this in the next commit'
Create new comment threads:
Start a new discussion with:
Create a review comment in MR #789 asking 'Could you add error handling here?'
Resolve discussions:
Mark discussions as resolved:
Resolve discussion def456 in MR #123
Get insights into discussions happening at the commit level:
View all commit discussions:
Show me commit discussions for MR #123
See complete commit conversation history:
Get all comments on commits in merge request #456
This is particularly useful for tracking review progress, understanding discussion history, and viewing comments in the context of specific code changes.
Create a gitlab-mcp.env file in each project for project-specific settings.
For system-wide settings, use environment variables:
export GITLAB_PROJECT_ID=12345
export GITLAB_ACCESS_TOKEN=glpat-xxxxxxxxxxxxxxxxxxxx
export GITLAB_URL=https://gitlab.com
read_api permissions and hasn't expired| Tool | Description | Parameters |
|---|---|---|
list_merge_requests |
List merge requests | state, target_branch, limit |
get_merge_request_details |
Get MR details | merge_request_iid |
get_merge_request_reviews |
Get reviews/discussions | merge_request_iid |
get_commit_discussions |
Get discussions on commits | merge_request_iid |
get_branch_merge_requests |
Find MRs for branch | branch_name |
reply_to_review_comment |
Reply to existing discussion | merge_request_iid, discussion_id, body |
create_review_comment |
Create new discussion thread | merge_request_iid, body |
resolve_review_discussion |
Resolve/unresolve discussion | merge_request_iid, discussion_id, resolved |
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "gitlab-mcp" '{"command":"/path/to/gitlab-mcp-server/run-mcp.sh","cwd":"/path/to/your-project"}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:
{
"mcpServers": {
"gitlab-mcp": {
"command": "/path/to/gitlab-mcp-server/run-mcp.sh",
"cwd": "/path/to/your-project"
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. Add this to your configuration file:
{
"mcpServers": {
"gitlab-mcp": {
"command": "/path/to/gitlab-mcp-server/run-mcp.sh",
"cwd": "/path/to/your-project"
}
}
}
3. Restart Claude Desktop for the changes to take effect