GitLab MR Comments MCP Server
Fetches merge request discussions/comments from GitLab via the GitLab REST API v4, returning file, line, comment text, author, timestamp, and resolution status with pagination and optional resolved-comment filtering.
Click on "Deploy 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 MR Comments MCP Server show comments from this MR: https://gitlab.com/group/project/-/merge_requests/42"
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 Comments MCP Server
A Model Context Protocol (MCP) server that fetches merge request comments from GitLab, including file names, line numbers, and comment text.
Features
Fetches comments from GitLab merge requests via the GitLab API
Returns structured data with:
File name (if comment is on a specific file)
Line number (if comment is on a specific line)
Comment text
Author information
Creation timestamp
Resolution status
Supports pagination
Optional filtering of resolved comments
SSL verification control
Related MCP server: GitLab Code Review MCP
Installation
npm install
npm run buildConfiguration
Set the following environment variables:
Required
GITLAB_HOSTorGITLAB_BASE_URL: Your GitLab instance URL (e.g.,https://gitlab.com)GITLAB_TOKENorGITLAB_PERSONAL_ACCESS_TOKEN: Your GitLab personal access token
Optional
GITLAB_SSL_VERIFY: SSL certificate verification. Set to0,false, ornoto disable (default: enabled)
Usage
As an MCP Server
Add to your MCP client configuration (e.g., Claude Desktop, Cline):
{
"mcpServers": {
"gitlab-mr-comments": {
"command": "node",
"args": ["/path/to/gitlab-mr-comments/dist/index.js"],
"env": {
"GITLAB_HOST": "https://gitlab.com",
"GITLAB_TOKEN": "your-gitlab-token-here"
}
}
}
}Using with AI Assistants
When you paste a GitLab merge request URL to an AI assistant that has this MCP server configured, the AI should automatically:
Parse the URL to extract the project path and MR IID
Call the tool with the correct parameters
Return the comments in a readable format
Example prompt:
Show me the comments from this merge request:
https://mars-gitlab.systemgroup.net/mars/general-market/-/merge_requests/7380The AI will extract:
Project:
mars/general-marketMR IID:
7380
And call the tool accordingly.
Tool: gitlab.get_merge_request_comments
Fetches comments for a specific merge request.
Parameters
project_id(string): Numeric project ID or full path (e.g.,"123"or"mygroup/myproject")merge_request_iid(string): Internal IID of the merge request (e.g.,"456")per_page(number, optional): Number of discussions per page (1-100, default: GitLab default of 20)page(number, optional): Page of discussions to fetch (default: 1)include_resolved(boolean, optional): Include resolved comments (default:false)
Extracting Parameters from a GitLab URL
Given a merge request URL like:
https://mars-gitlab.systemgroup.net/mars/general-market/-/merge_requests/7380Extract the parameters as:
project_id:"mars/general-market"(the path between the domain and/-/merge_requests/)merge_request_iid:"7380"(the number after/merge_requests/)
Example:
{
"project_id": "mars/general-market",
"merge_request_iid": "7380"
}Example Response
[
{
"file": "src/index.ts",
"line": 42,
"text": "Consider refactoring this function for better readability",
"author": "john.doe",
"created_at": "2024-11-08T10:30:00.000Z",
"resolved": false
},
{
"file": "README.md",
"line": 10,
"text": "This documentation needs to be updated",
"author": "jane.smith",
"created_at": "2024-11-07T14:20:00.000Z",
"resolved": true
},
{
"file": null,
"line": null,
"text": "Overall, this looks good to merge!",
"author": "bob.wilson",
"created_at": "2024-11-08T09:00:00.000Z",
"resolved": false
}
]Development
Build
npm run buildRun
npm startAPI Details
This server uses the GitLab REST API v4:
Endpoint:
/api/v4/projects/{project_id}/merge_requests/{merge_request_iid}/discussionsAuthentication: Personal Access Token via
PRIVATE-TOKENheader
Debugging & Troubleshooting
Viewing Logs
All logs are written to stderr with the prefix [MCP]. When running in an MCP client, these logs will typically appear in the client's log file or console.
Example logs on startup:
[MCP] ====================================
[MCP] GitLab MR Comments MCP Server
[MCP] Version: 0.1.0
[MCP] ====================================
[MCP] Node version: v20.x.x
[MCP] Platform: linux
[MCP] CWD: /path/to/project
[MCP] Creating stdio transport...
[MCP] Connecting server to transport...
[MCP] ====================================
[MCP] Server successfully connected!
[MCP] Ready to receive tool calls
[MCP] ====================================Example logs when tool is called:
[MCP] Tool called with args: {
"project_id": "mygroup/myproject",
"merge_request_iid": 123
}
[MCP] Starting fetchMergeRequestComments
[MCP] Resolving GitLab host from environment
[MCP] Resolved host: https://gitlab.com
[MCP] Resolving GitLab token from environment
[MCP] Token found (length: 20)
[MCP] SSL verification: enabled (default)
[MCP] Project ID: mygroup%2Fmyproject
[MCP] MR IID: 123
[MCP] Request URL: https://gitlab.com/api/v4/projects/mygroup%2Fmyproject/merge_requests/123/discussions
[MCP] Sending request to GitLab API...
[MCP] Response status: 200 OK
[MCP] Parsing response JSON...
[MCP] Received 5 discussions
[MCP] Include resolved: false
[MCP] Processed 12 comments
[MCP] Successfully fetched 12 commentsCommon Issues
1. Environment Variables Not Set
Symptom:
[MCP] ERROR: GITLAB_HOST environment variable not set
[MCP] Available env vars: []Solution: Make sure to set GITLAB_HOST and GITLAB_TOKEN in your MCP client configuration:
{
"env": {
"GITLAB_HOST": "https://gitlab.com",
"GITLAB_TOKEN": "your-token-here"
}
}2. Authentication Error
Symptom:
[MCP] Response status: 401 Unauthorized
[MCP] Error response body: {"message":"401 Unauthorized"}Solution:
Check that your GitLab token is valid
Ensure the token has
apiorread_apiscopeVerify you're using the correct token for your GitLab instance
3. Project Not Found
Symptom:
[MCP] Response status: 404 Not Found
[MCP] Error response body: {"message":"404 Project Not Found"}Solution:
Verify the project ID or path is correct
Ensure you have access to the project
For project paths with special characters, they will be automatically URL-encoded
4. SSL Certificate Issues
Symptom:
Error: self signed certificate in certificate chainSolution: Disable SSL verification (for development/testing only):
{
"env": {
"GITLAB_SSL_VERIFY": "0"
}
}Testing Locally
Use the included test script to verify your configuration:
# Set environment variables
export GITLAB_HOST="https://gitlab.com"
export GITLAB_TOKEN="your-token-here"
# Run test
./test-mcp.shThe server will start and show you all initialization logs. Press Ctrl+C to stop.
Checking MCP Client Logs
Different MCP clients store logs in different locations:
Claude Desktop (macOS):
tail -f ~/Library/Logs/Claude/mcp*.logClaude Desktop (Linux):
tail -f ~/.config/Claude/logs/mcp*.logCline (VS Code):
Check the VS Code Output panel
Select "Cline" from the dropdown
License
MIT
Available Tools
1 toolgitlab.get_merge_request_commentsB
Fetch comments for a GitLab merge request and return filename, line, and text. Provide the project path (e.g., "mars/general-market") and merge request IID (e.g., "7380").
Inputs: project_id (required), merge_request_iid (required), page, per_page, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
There is only one tool, so there is no possibility of confusing it with a sibling. Its purpose (fetch comments for a specific MR by project path and IID) is stated unambiguously.
The single name gitlab.get_merge_request_comments follows a clean namespace + verb_noun pattern in snake_case. No competing conventions exist to clash with.
The count matches the very narrow stated scope (reading MR comments), but a one-tool server is thin; even a read-only comments domain would normally include listing merge requests or fetching a single discussion thread.
The surface is read-only and has no way to post a reply, resolve a discussion, or list MRs to find the IID in the first place. Agents will frequently hit a dead end after retrieving the comments.
Maintenance
Related MCP Connectors
Configure discussions on a host-owned resource. Tools configure apps only; no comment bodies.
Read, reply to and resolve website feedback threads from your coding agent.
Browse and manage Reddit posts, comments, and threads. Fetch user activity, explore hot/new/rising…
Read requests and votes; with write access, manage feedback and draft changelogs. OAuth required.
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 gradedqualityBmaintenanceEnables AI agents to interact with GitLab repositories, allowing them to manage merge requests and issues including listing projects, fetching MR details and diffs, adding comments, and updating MR titles and descriptions.94MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with GitLab merge requests, review code changes, search projects, and create draft comments for code review workflows.ISC