GitLab MCP Server
Provides tools to fetch and filter comments from GitLab merge requests, including inline discussions and overview notes, with resolution-status filtering, system-note exclusion, file path extraction, thread grouping, and JSON or Markdown output.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
GitLab MCP Server
A Model Context Protocol (MCP) server for retrieving GitLab merge request comments.
π READ-ONLY: This server only fetches data from GitLab. It never modifies MR state, comments, or any other GitLab data.
What is this?
This MCP server enables AI coding agents (like Cursor, Claude Desktop, or any MCP-compatible client) to fetch comments from GitLab merge requests in a structured, agent-friendly format. It's designed to help agents:
π Compile unresolved comments into fix plans
π― Extract inline discussions with file paths and line numbers
π Filter feedback by resolution status
π Generate human-readable summaries
Related MCP server: GitLab Code Review MCP
Features
Unified Comment Structure: Combines inline discussions and overview notes into a single normalized format
Smart Filtering: Include/exclude system notes, filter by resolution status
File Path Extraction: Automatically extracts file paths from inline comments
Thread Context: Groups related comments by discussion thread
Dual Output Formats: JSON for programmatic use, Markdown for human reading
Retry Logic: Handles transient errors with exponential backoff
Pagination Support: Automatically fetches all pages
Security First: Token-based auth, secret redaction in logs
Quick Start
1. Install Dependencies
npm install2. Build the Server
npm run build3. Set Up GitLab Token
Create a Personal Access Token in GitLab:
Go to GitLab β Preferences β Access Tokens
Create a token with
read_apiscope (recommended for read-only access)Copy the token
4. Configure MCP Client
For Cursor
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"gitlab-mr-comments": {
"command": "node",
"args": ["/absolute/path/to/gitlab-mcp/dist/server.js"],
"env": {
"GITLAB_BASE_URL": "https://gitlab.com",
"GITLAB_TOKEN": "glpat_your_token_here"
}
}
}
}For Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%/Claude/claude_desktop_config.json (Windows):
{
"mcpServers": {
"gitlab-mr-comments": {
"command": "node",
"args": ["/absolute/path/to/gitlab-mcp/dist/server.js"],
"env": {
"GITLAB_BASE_URL": "https://gitlab.com",
"GITLAB_TOKEN": "glpat_your_token_here"
}
}
}
}5. Restart Your MCP Client
Restart Cursor or Claude Desktop for the configuration to take effect.
Available Tools
This MCP server provides the following tool(s):
gitlab_get_mr_comments
Fetches comments from a GitLab merge request, including inline discussions and overview notes.
Tool Name: gitlab_get_mr_comments
Description: Fetch comments from a GitLab merge request. Returns inline discussions and overview notes in a structured format. Supports filtering by resolution status and excluding system notes. Useful for AI agents to review feedback and plan code fixes.
When to use:
Review unresolved comments for a merge request
Get feedback on specific files
Generate fix plans from reviewer comments
Check resolution status of discussions
Usage
Basic Usage
Ask your AI agent:
"Fetch all unresolved comments from MR !123 in project my-org/my-repo"
The agent will automatically discover and use the gitlab_get_mr_comments tool with appropriate parameters.
Example Tool Call
{
"tool": "gitlab_get_mr_comments",
"arguments": {
"project": "my-org/my-repo",
"mr": 123,
"onlyUnresolved": true,
"includeSystem": false
}
}Tool Parameters
Parameter | Type | Default | Description |
| string | - | Required. Project path (e.g., |
| number | - | Required. MR IID (the |
| boolean |
| Include system-generated notes |
| boolean |
| Include overview (non-inline) notes |
| boolean |
| Only show resolved comments |
| boolean |
| Only show unresolved comments |
| number |
| Pagination size (1-100) |
| string |
| Output format: |
Note: onlyResolved and onlyUnresolved are mutually exclusive.
Agent Workflow Examples
Fix Plan Generation
User: "Review all unresolved comments on MR !456 and create a fix plan"
Agent:
1. Calls gitlab_get_mr_comments with onlyUnresolved=true
2. Groups comments by file_path
3. Generates prioritized fix plan:
- src/api/users.ts (3 comments)
β’ Line 45: Add error handling
β’ Line 78: Extract to helper
β’ Line 92: Add validationFile-Specific Review
User: "What feedback did reviewers leave on src/api/users.ts?"
Agent:
1. Fetches all comments from MR
2. Filters client-side for file_path = "src/api/users.ts"
3. Summarizes feedback for that specific fileRelease Readiness
User: "Summarize blocking issues on MR !789"
Agent:
1. Fetches all unresolved comments
2. Searches for keywords: "blocker", "must fix", "breaking"
3. Presents summary of blocking issuesEnvironment Variables
Variable | Default | Description |
|
| GitLab instance URL (for self-managed) |
| - | Required. Personal or Project Access Token |
|
| Logging level: |
|
| HTTP request timeout in milliseconds |
|
| Max retry attempts for transient errors |
|
| Log request/response payloads (dev only) |
Quick Setup:
cp .env.example .env
# Edit .env with your GITLAB_TOKENSee .env.example for detailed configuration options.
Self-Managed GitLab
To use with a self-managed GitLab instance:
{
"env": {
"GITLAB_BASE_URL": "https://gitlab.your-company.com",
"GITLAB_TOKEN": "glpat_your_token_here"
}
}Troubleshooting
"GITLAB_TOKEN environment variable is required"
Cause: The MCP server cannot find the GitLab token in the environment
Solution:
Verify MCP Configuration: Check your MCP config file and ensure
GITLAB_TOKENis in theenvsection:Cursor:
~/.cursor/mcp.jsonClaude Desktop:
~/Library/Application Support/Claude/claude_desktop_config.json(macOS)
Example:
{ "mcpServers": { "gitlab-mr-comments": { "command": "node", "args": ["/absolute/path/to/gitlab-mcp/dist/server.js"], "env": { "GITLAB_TOKEN": "glpat_your_token_here" } } } }Restart Your Client: After adding/changing the token, you MUST completely restart Cursor or Claude Desktop
Check Token Format: Ensure the token starts with
glpat-and has no extra spaces or quotesNote: A
.envfile in the project directory is NOT used when running as an MCP server. The token must be in the MCP client's config file.
"Authentication failed"
Cause: Invalid or missing token, insufficient permissions
Solution:
Verify
GITLAB_TOKENis set correctlyEnsure token has
read_apiscopeCheck token hasn't expired
Verify token has access to the project
"Project or MR not found"
Cause: Incorrect project path or MR number
Solution:
Use the project path (e.g.,
my-org/my-project), not the numeric IDUse the MR IID (the
!123number visible in the URL), not the internal IDEnsure your token has access to the project
"Rate limit exceeded"
Cause: Too many requests to GitLab API
Solution:
Wait a moment before retrying
Use
onlyUnresolvedfilter to reduce requestsSet
includeOverviewNotes: falseif not neededFor GitLab.com: free tier = 300 requests/minute
"Request timed out"
Cause: Large MR or slow network
Solution:
Increase
REQUEST_TIMEOUTenvironment variableUse filters to reduce data volume
Check network connectivity to GitLab instance
Server not showing up in Cursor/Claude
Cause: Configuration or path issues
Solution:
Verify absolute path to
dist/server.jsis correctCheck JSON syntax in config file
Restart Cursor/Claude Desktop after config changes
Check logs: Cursor logs in
~/.cursor/logs, Claude logs in~/Library/Logs/Claude
"Tools not found" or "What tools are available?"
Cause: AI agent can't discover the gitlab_get_mr_comments tool
Solution:
Verify server is connected:
Check MCP server status in your IDE (usually in settings/extensions)
Look for "gitlab-mr-comments" in the connected servers list
If not connected, see "Server not showing up" above
The tool name is:
gitlab_get_mr_commentsYou can tell your agent: "Use the gitlab_get_mr_comments tool to fetch comments from MR !530 in project zapier/team-sprout/templates"
Check server logs:
Look for "GitLab MR Comments tool registered successfully" message
If missing, the server may not have started properly
Restart both IDE and try again:
Sometimes tool discovery needs a fresh connection
Development
Run in Development Mode
npm run devRun Tests
npm testGenerate JSON Schema
npm run build
node scripts/generate-schema.tsLinting
npm run lint
npm run formatSecurity
Token Management
β DO: Use tokens with
read_apiscope (least privilege)β DO: Store tokens in environment variables or secure config files
β DON'T: Commit tokens to version control
β DON'T: Share tokens publicly
Read-Only Guarantee
This server is explicitly designed to be read-only:
β GitLab client only implements
GETrequestsβ No
POST,PUT,PATCH, orDELETEmethods existβ Recommended token scope is
read_api(read-only)β Integration tests verify no mutation endpoints are called
Data Privacy
All data is processed in-memory (no disk writes)
No caching or persistent storage
Secrets are automatically redacted from logs
No external services contacted (direct GitLab API only)
Architecture
AI Agent (Cursor/Claude)
β stdio (MCP Protocol)
MCP Server
β HTTPS (GET only)
GitLab REST APISee SYSTEM_DESIGN.md for detailed architecture documentation.
Performance
Typical Performance (GitLab.com, US region):
β€ 2s p50 latency for MRs with β€ 500 comments
β€ 5s p95 latency
Optimization Tips:
Use
onlyUnresolvedto reduce data volumeSet
includeOverviewNotes: falseif not neededUse
perPage: 100(maximum) to minimize roundtrips
Contributing
Contributions are welcome! Please read the system design document and follow the existing code patterns.
Key Principles
Read-Only: Never add write operations
Type Safety: Use TypeScript and Zod for validation
Error Handling: Provide actionable error messages
Testing: Add tests for new functionality
Documentation: Update README and examples
License
MIT License - see LICENSE file for details.
Support
Documentation: See
docs/directoryPRD: See
docs/GITLAB_MCP_PRD.mdSystem Design: See
docs/SYSTEM_DESIGN.md
Acknowledgments
Built with:
TypeScript, Zod, undici
Made with β€οΈ for AI-powered code review workflows
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Read projects, issues, merge requests and pipelines; create issues and comments in GitLab.
1Assess pull requests and read verdicts, findings, evidence and suggested fixes from coding agents.
Versioned artifact review for people and AI agents, with contextual comments and human control.
AI-native git hosting β repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to review GitLab merge requests by fetching changes, analyzing diffs, adding comments, and managing approvals through the GitLab API. Supports complete merge request analysis, file-specific reviews, and version comparisons.124MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to review GitLab merge requests by fetching diffs, analyzing code changes, adding comments, and managing approvals through the GitLab API. Supports comprehensive merge request analysis and version comparison for automated code review workflows.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with GitLab merge requests, review code changes, search projects, and create draft comments for code review workflows.ISC
- AlicenseAqualityDmaintenanceEnables retrieving comprehensive information about GitLab merge requests, including details, commits, diffs, discussions, approvals, and CI/CD status, through natural language.7577 npm1MIT