home / mcp / gitlab mcp server

GitLab MCP Server

gitlab-mcp-server

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "lucky-dersan-gitlab-mcp-server": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "GITLAB_TOKEN",
        "-e",
        "GITLAB_URL",
        "gitlab-mcp-server:latest"
      ],
      "env": {
        "GITLAB_URL": "https://gitlab.com/",
        "GITLAB_TOKEN": "token"
      }
    }
  }
}

This GitLab MCP Server lets you manage GitLab interactions through the Model Context Protocol (MCP). It runs as a Python-based MCP server built on FastMCP, and you connect it to your MCP client to perform repository actions, issues, merge requests, and more through a standardized client-server interface.

How to use

You connect your MCP client to the GitLab MCP Server to perform a range of repository operations and collaboration actions. Start by configuring your MCP client to use the server as an MCP endpoint. The server is designed to run locally or as part of your containerized environment and accepts environment variables for authentication and target GitLab instances. Once connected, you can create repositories, fork or delete them, read and write files, manage issues, create merge requests, and handle branches and tags via the MCP surface.

How to install

Prerequisites you need before installation:

Install Docker on your host if it is not already installed.

Build the MCP server image from its Dockerfile.

docker build -t gitlab-mcp-server .

Run the MCP server container with the required environment variables. You will provide your GitLab token and the GitLab instance URL when starting the container.

docker run --rm -i -e GITLAB_TOKEN=YOUR_GITLAB_TOKEN \
  -e GITLAB_URL=https://gitlab.com/ \
  gitlab-mcp-server:latest

Additional notes

Getting a GitLab access token is required to authorize actions against your GitLab instance. Create a personal access token with the necessary scopes for API access and repository operations.

Steps to obtain the token: Log in to GitLab, go to Settings -> Access Tokens, create a new token with scopes such as api, read_repository, and write_repository, then copy the generated token (shown only once).

Configuration example for MCP clients

json
{
  "mcpServers": {
    "gitlab": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "GITLAB_TOKEN",
        "-e",
        "GITLAB_URL",
        "gitlab-mcp-server:latest"
      ],
      "env": {
        "GITLAB_TOKEN": "token",
        "GITLAB_URL": "https://gitlab.com/"
      }
    }
  }
}
``n

Available tools

create_repository

Create a new repository in GitLab for the configured user or group.

fork_repository

Fork an existing GitLab repository into the user's namespace or a target namespace.

delete_repository

Delete a repository from GitLab, removing it from the organization or user space.

search_repositories

Search repositories available to the authenticated user or token scope.

create_or_update_file

Create a new file or update an existing file in a repository at a specified path.

push_files

Push a set of files to a repository, creating commits as needed.

get_file_contents

Retrieve the contents of a file from a repository path.

create_issue

Create a new issue in a GitLab repository.

get_issues

List or retrieve issues for a repository.

create_merge_request

Open a new merge request between branches or forks.

get_merge_request_diff

Fetch the diff for a merge request to review changes.

create_branches

Create new branches in a repository.

delete_branches

Delete specified branches from a repository.

create_tags

Create new tags in a repository.

delete_tags

Delete specified tags from a repository.