This MCP GitLab Review Server extends Model Context Protocol with features for posting review comments on merge requests in GitLab. It enables you to retrieve merge request information, fetch the latest versions, and post review comments directly through API endpoints.
Before using the MCP GitLab Review Server, you need to configure the following environment variables:
{
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "xxxxxx",
"GITLAB_API_URL": "xxxxx"
}
}
Make sure to:
xxxxxx
with your actual GitLab Personal Access TokenGITLAB_API_URL
to your GitLab instance API URL (e.g., https://gitlab.com/api
)The server provides three main API endpoints for interacting with GitLab merge requests:
To get details about a specific merge request:
GET /api/v4/projects/:project_id/merge_requests/:merge_request_iid
Replace:
:project_id
with your project's ID:merge_request_iid
with the internal ID of the merge requestTo retrieve the latest version of a merge request:
GET /api/v4/projects/:project_id/merge_requests/:merge_request_iid/versions
This endpoint is useful for ensuring you're working with the most current version of the code being reviewed.
To add review comments to a merge request:
POST /api/v4/projects/:project_id/merge_requests/:merge_request_iid/discussions
This endpoint allows you to post comments and feedback directly on the merge request, facilitating code review workflows.
When posting comments, you'll need to provide appropriate JSON payloads with your review content according to the GitLab API specifications.
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.