GitLab MCP server

Integrates with GitLab to enable repository management, code review, CI/CD operations, and project administration through domain-specific API managers that support both cloud and self-hosted instances
Back to servers
Provider
Rifqi Fadhlillah
Release date
Mar 25, 2025
Language
TypeScript
Stats
6 stars

The GitLab MCP Server allows you to interact with your GitLab account through the Model Context Protocol (MCP). It enables powerful operations like analyzing merge requests, reviewing code, fetching diffs, and managing repositories directly from MCP-compatible AI assistants.

Installation Requirements

Prerequisites

  • Node.js (v16 or higher)
  • npm
  • A GitLab account with an API token

Installation Steps

  1. Clone the repository:
git clone https://github.com/rifqi96/mcp-gitlab.git
cd mcp-gitlab
  1. Install dependencies:
npm install
  1. Build the server:
npm run build

Configuration

The GitLab MCP Server requires configuration in your MCP settings file to authenticate with the GitLab API.

For Cursor/Roo Cline

Add this to your MCP settings file at ~/Library/Application Support/Cursor/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json:

{
  "mcpServers": {
    "gitlab": {
      "command": "node",
      "args": [
        "/path/to/mcp-gitlab/build/index.js"
      ],
      "env": {
        "GITLAB_API_TOKEN": "YOUR_GITLAB_API_TOKEN",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

For Claude Desktop

Add this to your MCP settings file at ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "gitlab": {
      "command": "node",
      "args": [
        "/path/to/mcp-gitlab/build/index.js"
      ],
      "env": {
        "GITLAB_API_TOKEN": "YOUR_GITLAB_API_TOKEN",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

Replace /path/to/mcp-gitlab/build/index.js with the actual path to the built server on your system, and YOUR_GITLAB_API_TOKEN with your GitLab API token. You can generate a token in GitLab under Settings > Access Tokens.

Using the Server

After installation and configuration, you can use the GitLab MCP Server through your MCP-compatible AI assistant. Here are some example prompts:

Basic Repository Operations

Listing Projects

Could you list my GitLab projects?

Getting Merge Request Details

Can you show me the details of merge request with ID 123 in the project 'mygroup/myproject'?

Adding Comments to Merge Requests

Please add a comment to merge request 123 in project 'mygroup/myproject' saying "This looks good, but please add more tests."

Adding Internal Notes

Add an internal note to merge request 123 in project 'mygroup/myproject' that says "Needs security review before merging."

Advanced Operations

Updating Merge Request Properties

Update the title of merge request 123 in project 'mygroup/myproject' to "Fix login page performance issues" and update the description to include "This PR addresses the slow loading times on the login page by optimizing database queries."

Comparing Branches

Compare the 'feature-branch' with 'main' in the project 'mygroup/myproject' and show me the differences.

Practical Workflows

Code Review Workflow

  1. Request merge request details:

    Show me merge request 123 in project 'mygroup/myproject'
    
  2. Examine the changes:

    Show me the changes for this merge request
    
  3. Provide feedback:

    Add an internal note with my review comments
    
  4. Update merge request information:

    Update the merge request title to better reflect the changes
    

Project Exploration Workflow

  1. List available projects:

    List all my GitLab projects
    
  2. Get project details:

    Show me the details of project 'mygroup/myproject'
    
  3. Explore branches:

    List all branches in this project
    
  4. View specific files:

    Show me the content of the README.md file in the main branch
    

Available Features

Repository Management

  • List and retrieve project details
  • Manage branches and repositories
  • Work with merge requests and diffs
  • Add comments and internal notes
  • Update merge request attributes
  • List and work with issues
  • Compare file contents across branches

Project Configuration

  • Manage project integrations
  • Configure Slack integration
  • Set up and manage webhooks

CI/CD Operations

  • Work with pipeline trigger tokens
  • Manage CI/CD variables
  • Trigger and control pipelines

User Management

  • List and manage users
  • Work with groups and memberships
  • Manage project access levels

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