GitLab MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add -e "GITLAB_TOKEN=${GITLAB_TOKEN}" gitlab-mcp-server -- bunx @carmeloricarte/gitlab-mcp-server
Required:GITLAB_TOKEN+ 1 optional
README.md

A Model Context Protocol (MCP) server for GitLab integration

GitLab MCP Server

A Model Context Protocol (MCP) server for GitLab integration with Claude Code and AI assistants.

Features

  • Projects: List and get project details
  • Branches: List and create branches
  • Issues: Create and list issues
  • Merge Requests: Create and list MRs
  • Files: Read and write repository files
  • Search: Search code in repositories

Requirements

  • Bun >= 1.0 or Node.js >= 18
  • GitLab Personal Access Token with api scope

Installation

The server is published on npm and can be run directly:

# Using Bun (recommended)
bunx @carmeloricarte/gitlab-mcp-server

# Using Node.js
npx @carmeloricarte/gitlab-mcp-server

No need to clone the repository or install dependencies manually.

Configuration

Set the following environment variables:

Variable Required Default Description
GITLAB_TOKEN Yes - GitLab Personal Access Token
GITLAB_HOST No https://gitlab.com GitLab instance URL

For self-hosted GitLab with self-signed certificates:

export NODE_TLS_REJECT_UNAUTHORIZED=0

Environment Variables Setup

There are two approaches to configure credentials:

Option A: Variables in MCP Config (Simplest)

Pass all variables directly in the MCP configuration. Easiest for quick setup on new machines.

⚠️ Note: Token is stored in the config file (local, private). Acceptable for personal use.

Option B: System Environment Variables (More Secure)

Keep sensitive tokens at system/user level, only pass non-sensitive values in MCP config.

Windows (PowerShell)
# Set permanently for current user
[Environment]::SetEnvironmentVariable("GITLAB_TOKEN", "glpat-your-token", "User")
[Environment]::SetEnvironmentVariable("GITLAB_HOST", "https://your-gitlab.com", "User")

# Verify
[Environment]::GetEnvironmentVariable("GITLAB_TOKEN", "User")

Restart your terminal/IDE after setting variables.

macOS / Linux
# Add to ~/.zshrc (macOS) or ~/.bashrc (Linux)
echo 'export GITLAB_TOKEN="glpat-your-token"' >> ~/.zshrc
echo 'export GITLAB_HOST="https://your-gitlab.com"' >> ~/.zshrc

# Reload
source ~/.zshrc

# Verify
echo $GITLAB_TOKEN

IDE / Tool Configuration

💡 Tip: Use bunx if you have Bun installed, or npx for Node.js. Both work identically.

⚠️ Important: ${VARIABLE} syntax does NOT work in most MCP configs - values are treated as literal strings, not resolved. Use Option A (hardcoded values) or Option B (system variables that the server reads from process.env).

⚠️ Windows Configuration

On Windows, you must wrap npx or bunx commands with cmd /c. Use this format:

{
  "command": "cmd",
  "args": ["/c", "npx", "-y", "@carmeloricarte/gitlab-mcp-server"]
}

Or with Bun:

{
  "command": "cmd",
  "args": ["/c", "bunx", "@carmeloricarte/gitlab-mcp-server"]
}

Important: The package name must always be the last argument in the args array.


Claude Code CLI

Option A: All variables in config
claude mcp add-json GitLab '{
  "type": "stdio",
  "command": "bunx",
  "args": ["@carmeloricarte/gitlab-mcp-server"],
  "env": {
    "GITLAB_HOST": "https://your-gitlab.com",
    "GITLAB_TOKEN": "glpat-your-token",
    "NODE_TLS_REJECT_UNAUTHORIZED": "0"
  }
}'
Option B: Token from system env

Set GITLAB_TOKEN as system variable (see above), then:

claude mcp add-json GitLab '{
  "type": "stdio",
  "command": "bunx",
  "args": ["@carmeloricarte/gitlab-mcp-server"],
  "env": {
    "GITLAB_HOST": "https://your-gitlab.com",
    "NODE_TLS_REJECT_UNAUTHORIZED": "0"
  }
}'

Verify:

claude mcp list
# Expected: GitLab: bunx ... - ✓ Connected

VS Code (with MCP extension)

Edit ~/.vscode/mcp.json or .vscode/mcp.json in your project:

{
  "servers": {
    "GitLab": {
      "type": "stdio",
      "command": "bunx",
      "args": ["@carmeloricarte/gitlab-mcp-server"],
      "env": {
        "GITLAB_HOST": "https://your-gitlab.com",
        "GITLAB_TOKEN": "glpat-your-token",
        "NODE_TLS_REJECT_UNAUTHORIZED": "0"
      }
    }
  }
}

Cursor

Edit ~/.cursor/mcp.json:

{
  "mcpServers": {
    "GitLab": {
      "command": "bunx",
      "args": ["@carmeloricarte/gitlab-mcp-server"],
      "env": {
        "GITLAB_HOST": "https://your-gitlab.com",
        "GITLAB_TOKEN"

Tools (10)

list_projectsList and get project details from GitLab
list_branchesList branches in a repository
create_branchCreate a new branch in a repository
list_issuesList issues for a project
create_issueCreate a new issue in a project
list_merge_requestsList merge requests for a project
create_merge_requestCreate a new merge request
read_fileRead content of a file from the repository
write_fileWrite content to a file in the repository
search_codeSearch for code within a repository

Environment Variables

GITLAB_TOKENrequiredGitLab Personal Access Token with api scope
GITLAB_HOSTGitLab instance URL (defaults to https://gitlab.com)

Configuration

claude_desktop_config.json
{"GitLab": {"type": "stdio", "command": "bunx", "args": ["@carmeloricarte/gitlab-mcp-server"], "env": {"GITLAB_HOST": "https://your-gitlab.com", "GITLAB_TOKEN": "glpat-your-token"}}}

Try it

List all the open issues in my current project.
Create a new branch named 'feature/login-fix' from the main branch.
Search for the implementation of the authentication middleware in the repository.
Read the README.md file from the main branch of the project.
Create a new merge request to merge 'feature/login-fix' into 'main' with the title 'Fix login bug'.

Frequently Asked Questions

What are the key features of GitLab MCP Server?

List and retrieve detailed project information. Create and manage repository branches. Automate issue tracking and creation. Manage merge request lifecycles. Direct read and write access to repository files.

What can I use GitLab MCP Server for?

Automating the creation of issues based on AI-identified bugs in code. Streamlining the merge request process by having AI draft descriptions and verify changes. Quickly searching through large codebases to find specific implementation details. Performing bulk file updates or refactoring across a repository via AI instructions.

How do I install GitLab MCP Server?

Install GitLab MCP Server by running: bunx @carmeloricarte/gitlab-mcp-server

What MCP clients work with GitLab MCP Server?

GitLab MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep GitLab MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare