Back to MCP Catalog

GitLab MCP Server

Version ControlTypeScript
Interact with GitLab repositories, issues, and merge requests
Available Tools

create_or_update_file

Create or update a single file in a project

project_idfile_pathcontentcommit_messagebranchprevious_path

push_files

Push multiple files in a single commit

project_idbranchfilescommit_message

search_repositories

Search for GitLab projects

searchpageper_page

create_repository

Create a new GitLab project

namedescriptionvisibilityinitialize_with_readme

get_file_contents

Get contents of a file or directory

project_idfile_pathref

create_issue

Create a new issue

project_idtitledescriptionassignee_idslabelsmilestone_id

create_merge_request

Create a new merge request

project_idtitledescriptionsource_branchtarget_branchdraftallow_collaboration

fork_repository

Fork a project

project_idnamespace

create_branch

Create a new branch

project_idbranchref

The GitLab MCP server provides a comprehensive interface to GitLab's API, enabling AI assistants to manage repositories, files, issues, and merge requests. It supports both single and batch file operations while maintaining proper Git history, and includes features like automatic branch creation and detailed error handling. With this MCP, AI assistants can search for repositories, create or update files, push multiple files in a single commit, create issues and merge requests, fork repositories, and more. It works with both gitlab.com and self-hosted GitLab instances.

Overview

The GitLab MCP server enables AI assistants to interact with GitLab repositories and project management features. It provides a seamless interface to GitLab's API, allowing for repository management, file operations, issue tracking, and merge request handling.

Setup Instructions

Prerequisites

To use the GitLab MCP server, you'll need:

  1. A GitLab account (either on gitlab.com or a self-hosted instance)
  2. A Personal Access Token with appropriate permissions

Creating a Personal Access Token

  1. Log in to your GitLab account
  2. Go to User Settings > Access Tokens
  3. Create a new token with the following scopes:
    • api for full API access
    • read_api for read-only access
    • read_repository and write_repository for repository operations
  4. Save your token securely - you'll need it for configuration

Installation Options

You can use the GitLab MCP server with various AI assistants that support the Model Context Protocol. Here are the installation methods:

Using Docker

Add the following configuration to your AI assistant's MCP configuration:

{
  "mcpServers": {
    "gitlab": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "GITLAB_PERSONAL_ACCESS_TOKEN",
        "-e",
        "GITLAB_API_URL",
        "mcp/gitlab"
      ],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

Using NPX

Add the following configuration to your AI assistant's MCP configuration:

{
  "mcpServers": {
    "gitlab": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-gitlab"
      ],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

Configuration Options

  • GITLAB_PERSONAL_ACCESS_TOKEN: Your GitLab personal access token (required)
  • GITLAB_API_URL: The API URL for your GitLab instance (optional, defaults to https://gitlab.com/api/v4)

Using with Different AI Assistants

Claude Desktop

Add the configuration to your claude_desktop_config.json file.

VS Code

For VS Code users, you can use the one-click installation buttons provided in the repository README, or manually add the configuration to your VS Code settings.

Usage Examples

Here are some examples of how to use the GitLab MCP server with an AI assistant:

Creating or Updating a File

You can create a new file in my GitLab repository with the following details:
- Project ID: myusername/myproject
- File path: src/utils/helpers.js
- Content: A utility function to format dates
- Branch: feature/date-utils
- Commit message: "Add date formatting utility function"

Creating an Issue

Please create a new issue in my GitLab project:
- Project ID: myusername/myproject
- Title: "Implement user authentication"
- Description: "We need to add user authentication using OAuth2 with support for Google and GitHub providers."
- Labels: ["feature", "security"]

Creating a Merge Request

Create a merge request for the changes I've made:
- Project ID: myusername/myproject
- Title: "Add date formatting utilities"
- Source branch: feature/date-utils
- Target branch: main
- Description: "This PR adds utility functions for formatting dates in various formats."

Troubleshooting

If you encounter issues with the GitLab MCP server:

  1. Verify your personal access token has the correct permissions
  2. Check that the GitLab API URL is correct for your instance
  3. Ensure your token hasn't expired
  4. For self-hosted instances, verify API access is enabled

For more detailed information, refer to the GitLab API documentation.

Related MCPs

GitHub API
Version ControlTypeScript

Interact with GitHub repositories, issues, pull requests, and more through the GitHub API

Gitee
Version ControlOther

A Chinese alternative to GitHub for code hosting and collaboration

Git Repository Manager
Version ControlPython

Interact with and manage Git repositories through LLM interfaces

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.