GitLab Review MCP server

Integrates with GitLab's API to automate code review processes, enabling retrieval of merge request details and posting of discussion comments.
Back to servers
Provider
Photosynth Inc
Release date
Jan 08, 2025
Language
TypeScript
Stats
2 stars

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.

Setup and Configuration

Environment Variables

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:

  • Replace xxxxxx with your actual GitLab Personal Access Token
  • Set GITLAB_API_URL to your GitLab instance API URL (e.g., https://gitlab.com/api)

Using the API

The server provides three main API endpoints for interacting with GitLab merge requests:

Retrieving Merge Request Information

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 request

Fetching Latest Merge Request Version

To 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.

Posting Review Comments

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.

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a 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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later