The GitLab MCP server enables AI assistants to interact with GitLab for managing merge requests, pipelines, tests, and discussions.
Merge Request Management:
List and filter merge requests by state (opened/closed/merged/all), target branch, or specific branch
View detailed merge request information including descriptions, metadata, and status
Find merge requests associated with specific branches
Review and Discussion Management:
View all reviews and discussions with discussion IDs and note IDs
Reply to existing discussion threads
Create new discussion threads and review comments
Resolve or unresolve discussion threads
View commit-level discussions and comments within merge requests
CI/CD Pipeline and Testing:
View pipeline status with all jobs grouped by status (failed/running/success) and job IDs
Fetch job logs using job IDs for debugging CI/CD failures
Get detailed test reports with test names, error messages, stack traces, and file locations for debugging
Access test summaries showing pass/fail counts, pass rates, and execution times for quick overview
Typical Use Cases:
Participate in code reviews and manage discussion workflow
Debug test failures with structured reports instead of parsing full logs
Track CI/CD pipeline status and investigate job failures
Monitor commit-level feedback and review progress
Enables interaction with GitLab repositories to manage merge requests, including listing open MRs, viewing MR details, accessing reviews and discussions, finding MRs for specific branches, replying to review comments, creating new discussion threads, and resolving discussions.
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 MCP Servershow me reviews for MR #123"
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 MR MCP
Connect your AI assistant to GitLab. Ask questions like "List open merge requests", "Show me reviews for MR #123", "Get commit discussions for MR #456", or "Find merge requests for the feature branch" directly in your chat.
Table of Contents
Related MCP server: GitHub MCP Tools
Quick Setup
Installation
Note: Using
pipxoruv toolis recommended as they automatically add thegitlab-mcpcommand to your PATH. If usingpip install, ensure your Python scripts directory is in PATH, or use the full path to the command.
Get your GitLab token
Go to GitLab → Settings → Access Tokens
Create token with
read_apiscope (addapiscope if you want write access)Copy the token
Configure your MCP client
Multi-Project Setup (Recommended)
For working with multiple GitLab projects, add to your global MCP config (~/.cursor/mcp.json for Cursor):
This single configuration works across all your projects. Use search_projects or list_my_projects to find project IDs, then specify project_id in your requests.
Single-Project Setup
For working with a single project, you can set a default project ID:
Restart your MCP client and start asking GitLab questions!
What You Can Do
Once connected, try these commands in your chat:
Multi-Project Workflow
"What projects do I have access to?"
"Search for the backend project"
"Show open MRs for project 12345"
"List merge requests for group/my-project"
Single-Project Commands
"List open merge requests"
"Show me details for merge request 456"
"Get reviews and discussions for MR #123"
"Show me the test summary for MR #456"
"What tests failed in merge request #789?"
"Show me the pipeline for MR #456"
"Get the failed job logs for merge request #789"
"Show me commit discussions for MR #456"
"Get all comments on commits in merge request #789"
"Find merge requests for the feature/auth-improvements branch"
"Show me closed merge requests targeting main"
"Reply to discussion abc123 in MR #456 with 'Thanks for the feedback!'"
"Create a new review comment in MR #789 asking about the error handling"
"Resolve discussion def456 in MR #123"
"Approve merge request #456"
"Merge MR #123 with squash"
"Merge MR #789 when pipeline succeeds"
Working with Review Comments
The enhanced review tools allow you to interact with merge request discussions:
First, get the reviews to see discussion IDs:
"Show me reviews for MR #123"Reply to specific discussions using the discussion ID:
"Reply to discussion abc123 in MR #456 with 'I'll fix this in the next commit'"Create new discussion threads to start conversations:
"Create a review comment in MR #789 asking 'Could you add error handling here?'"Resolve discussions when issues are addressed:
"Resolve discussion def456 in MR #123"
Note: The get_merge_request_reviews tool now displays discussion IDs and note IDs in the output, making it easy to reference specific discussions when replying or resolving.
Approving and Merging
Complete the MR lifecycle with approval and merge tools:
Approve a merge request:
"Approve MR #123"Merge with options:
"Merge MR #456 with squash" "Merge MR #789 and remove source branch" "Merge MR #123 when pipeline succeeds"Revoke approval (if needed):
"Unapprove MR #456"
Merge Options:
squash- Squash commits into a single commitshould_remove_source_branch- Delete source branch after mergemerge_when_pipeline_succeeds- Auto-merge when pipeline passessha- Ensure HEAD hasn't changed (safety check)
Note: You cannot approve your own MRs. The merge will fail if the MR has conflicts, is in draft status, or doesn't meet approval requirements.
Working with Test Reports (Recommended for Test Failures)
GitLab provides two tools for checking test results - use the summary for quick checks, and the full report for detailed debugging:
Option 1: Test Summary (Fast & Lightweight) ⚡
Use get_pipeline_test_summary for a quick overview:
What You Get:
📊 Pass/fail counts per test suite
⏱️ Total execution time
🎯 Pass rate percentage
⚡ Fast - doesn't include detailed error messages
Option 2: Full Test Report (Detailed) 🔍
Use get_merge_request_test_report for detailed debugging:
What You Get:
✅ Specific test names that passed/failed
❌ Error messages and stack traces
📦 Test suites organized by class/file
⏱️ Execution time for each test
📊 Pass rate and summary statistics
📄 File paths and line numbers
How Both Work:
Automatically fetch the latest pipeline for the merge request
Retrieve test data from that pipeline (uses GitLab's
/pipelines/:pipeline_id/test_reportor/test_report_summaryAPI)
Example Output:
Why Use This Instead of Job Logs?
🎯 No noise: Only test results, no build/setup output
📊 Structured data: Easy for AI to understand and suggest fixes
🚀 Fast: Much smaller than full job logs
🔍 Precise: Shows exact test names and error locations
Requirements:
Your CI must upload test results using artifacts:reports:junit in .gitlab-ci.yml:
Working with Pipeline Jobs and Logs
The pipeline tools provide a two-step workflow for debugging test failures:
Step 1: Get Pipeline Overview
Use get_merge_request_pipeline to see all jobs and their statuses:
What You Get:
Pipeline overview (status, duration, coverage)
All jobs grouped by status (failed, running, success)
Job IDs for each job (use these to fetch logs)
Direct links to view jobs in GitLab
Job-level timing and stage information
Step 2: Get Specific Job Logs
Use get_job_log with a job ID to fetch the actual output:
What You Get:
Complete job output/trace
Log size and line count
Automatically truncated to last 15,000 characters for very long logs
Typical Workflow:
Why Two Tools?
Performance: Only fetch logs when needed (not all at once)
Flexibility: Check any job's log (failed, successful, or running)
Context Efficient: Avoid dumping huge logs unnecessarily
Working with Commit Discussions
The get_commit_discussions tool provides comprehensive insights into discussions and comments on individual commits within a merge request:
View all commit discussions for a merge request:
"Show me commit discussions for MR #123"Get detailed commit conversation history:
"Get all comments on commits in merge request #456"
This tool is particularly useful for:
Code Review Tracking: See all feedback on specific commits
Discussion History: Understand the evolution of code discussions
Commit-Level Context: View comments tied to specific code changes
Review Progress: Monitor which commits have been discussed
Technical Implementation:
Uses
/projects/:project_id/merge_requests/:merge_request_iid/commitsto get all commits with proper paginationFetches ALL merge request discussions using
/projects/:project_id/merge_requests/:merge_request_iid/discussionswith pagination supportFilters discussions by commit SHA using position data to show commit-specific conversations
Handles both individual comments and discussion threads correctly
The output includes:
Summary of total commits and discussion counts
Individual commit details (SHA, title, author, date)
All discussions and comments for each commit with file positions
Complete conversation threads with replies
File positions for diff-related comments
Thread conversations with replies
Configuration Options
MCP Config (Recommended)
Configure environment variables directly in your MCP client config as shown in Quick Setup. This keeps project-specific settings with the project.
Environment Variables
Alternatively, set environment variables in your shell:
SOCKS Proxy Support
Route all GitLab API requests through a SOCKS5 proxy by setting SOCKS_PROXY:
Or via environment variable:
When SOCKS_PROXY is not set, connections are made directly (no proxy).
Find Your Project ID
Go to your GitLab project → Settings → General → Project ID
Or check the URL:
https://gitlab.com/username/project(use the numeric ID)
Troubleshooting
Authentication Error: Verify your token has read_api permissions and is not expired.
Project Not Found: Double-check your project ID is correct (it's a number, not the project name).
Connection Issues: Make sure your GitLab URL is accessible and correct.
Script Not Found: Ensure the path in your MCP config points to the actual server location and the script is executable.
Tool Reference
Project Discovery Tools
Tool | Description | Parameters |
| Primary - Fast search by name (use this first) |
|
| List all projects (slower, use for browsing) |
|
Merge Request Tools
All project-scoped tools accept an optional project_id parameter. If not provided, falls back to GITLAB_PROJECT_ID env var.
Tool | Description | Parameters |
| List merge requests |
|
| Get MR details |
|
| Create a new merge request |
|
| Update an existing merge request |
|
| Merge an MR |
|
| Approve an MR |
|
| Revoke approval from an MR |
|
| Get test summary (fast overview) |
|
| Get detailed test failure reports |
|
| Get pipeline with all jobs |
|
| Get trace/output for specific job |
|
| Get reviews/discussions |
|
| Get discussions on commits |
|
| Find MRs for branch |
|
| Reply to existing discussion |
|
| Create new discussion thread |
|
| Resolve/unresolve discussion |
|
| List project members |
|
| List project labels |
|
Roadmap
Recently Added
v1.4.0: Project discovery tools, MCP best practices (tool titles, annotations), improved prompts
v1.3.1: Fixed multi-workspace environment variable conflict in Cursor
v1.3.0: SOCKS5 proxy support for routing GitLab API requests
v1.2.0: Merge, approve, and unapprove MR tools - complete MR lifecycle
v1.1.0: Create and update MR tools, cleaner output formatting
Coming Next
Issue Management - List, create, update issues and add comments
Inline Comments - Add code review comments on specific lines
Considering
Lightweight file list for MRs (changed files without full diff)
Rebase MR via API
Out of Scope
Branch operations, file content fetching, and full diffs are intentionally not included - use git locally for these tasks, it's faster and more capable.
Have a feature request? Open an issue!
Development
Project Structure
Adding Tools
Create new file in
gitlab_mr_mcp/tools/directoryAdd import and export to
gitlab_mr_mcp/tools/__init__.pyAdd to
list_tools()ingitlab_mr_mcp/server.pyAdd handler to
call_tool()ingitlab_mr_mcp/server.py
Adding Prompts
Prompts provide workflow guidance to AI assistants. Add new prompts in gitlab_mr_mcp/prompts.py:
Define the prompt content as a string constant
Add entry to the
PROMPTSdictionary withtitle,description, andcontent
Development Setup
Install development dependencies:
Available make commands:
Set up pre-commit hooks:
This will automatically check and format your code for:
✨ Trailing whitespace - auto-removed
📄 End-of-file issues - auto-fixed
🎨 Code formatting (black) - auto-formatted
📦 Import sorting (isort) - auto-organized
🐍 Python style (flake8) - linted with bugbear & print detection
🔒 Security issues (bandit) - security checks
📋 YAML/JSON formatting - validated
Format all existing code (first time only):
Run pre-commit manually on all files:
Running Tests
Security Notes
Never commit access tokens to version control
Use project-specific tokens with minimal permissions (
read_apiscope)Rotate tokens regularly
Store tokens in your MCP config (which should not be committed)
Support
Check GitLab API documentation
Open issues at github.com/amirsina-mandegari/gitlab-mr-mcp
License
MIT License - see LICENSE file for details.