Labsco
ZephyrDeng logo

GitLab

β˜… 6

from ZephyrDeng

A GitLab integration server providing access to GitLab's RESTful API tools, built on the fastmcp framework.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

δΈ­ζ–‡η‰ˆ

Build Status Node Version License

Downloads npm version smithery badge

<a href="https://glama.ai/mcp/servers/@ZephyrDeng/mcp-server-gitlab"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@ZephyrDeng/mcp-server-gitlab/badge" /> </a>

mcp-gitlab MCP Server (English)

A GitLab integration server built on the fastmcp framework, providing various GitLab RESTful API tools. Supports integration with Claude, Smithery, and other platforms.

Features

  • GitlabSearchUserProjectsTool: Search users and their active projects by username
  • GitlabGetUserTasksTool: Get current user's pending tasks
  • GitlabSearchProjectDetailsTool: Search projects and details
  • GitlabCreateMRCommentTool: Add comments to merge requests
  • GitlabAcceptMRTool: Accept and merge merge requests
  • GitlabUpdateMRTool: Update merge request assignee, reviewers, title, description, and labels
  • GitlabCreateMRTool: Create a new merge request with assignee and reviewers
  • GitlabRawApiTool: Call any GitLab API with custom parameters

Environment Variables

Copy & paste β€” that's it
# Required for all modes (optional for httpStream mode - can be provided via HTTP headers)
GITLAB_API_URL=https://your-gitlab-instance.com

# Required for stdio mode, optional for httpStream mode
# (can be provided via HTTP headers in httpStream mode)
GITLAB_TOKEN=your_access_token

# Optional: Provide a mapping from usernames to user IDs (JSON string)
# This can reduce API calls, especially when referencing the same users frequently
# Example: '{"username1": 123, "username2": 456}'
GITLAB_USER_MAPPING={"username1": 123, "username2": 456}

# Optional: Provide a mapping from project names to project IDs (JSON string)
# Project IDs can be numbers or strings (e.g., 'group/project')
# This can reduce API calls and ensure the correct project is used
# Example: '{"project-name-a": 1001, "group/project-b": "group/project-b"}'
GITLAB_PROJECT_MAPPING={"project-name-a": 1001, "group/project-b": "group/project-b"}

# MCP Transport Configuration (Optional)
# Transport type: stdio (default) or httpStream  
MCP_TRANSPORT_TYPE=stdio

# HTTP Stream Configuration (Only used when MCP_TRANSPORT_TYPE=httpStream)
# Server binding address (default: 0.0.0.0 for httpStream, localhost for stdio)
# For Docker deployments, use 0.0.0.0 to allow external access
MCP_HOST=0.0.0.0

# Server port (default: 3000)
MCP_PORT=3000

# API endpoint path (default: /mcp)
MCP_ENDPOINT=/mcp

Transport Modes

This server supports two transport modes:

1. Stdio Transport (Default)

  • Best for local development and direct integration with MCP clients
  • Uses stdin/stdout for communication
  • No network configuration needed

2. HTTP Stream Transport

  • Enables server deployment for remote access
  • Uses HTTP POST requests with streaming responses
  • Allows multiple clients to connect to the same server instance
  • Ideal for production deployments
  • Supports dynamic token authentication via HTTP headers

When using HTTP Stream mode, clients can connect to:

Copy & paste β€” that's it
POST http://localhost:3000/mcp
Content-Type: application/json

Authentication Methods

HTTP Stream mode supports multiple ways to provide GitLab tokens and instance URLs:

Token Authentication:

1. Bearer Token (Recommended):

Copy & paste β€” that's it
POST http://localhost:3000/mcp
Content-Type: application/json
Authorization: Bearer your-gitlab-access-token

2. Private Token Header:

Copy & paste β€” that's it
POST http://localhost:3000/mcp
Content-Type: application/json
PRIVATE-TOKEN: your-gitlab-access-token

3. Alternative Private Token Header:

Copy & paste β€” that's it
POST http://localhost:3000/mcp
Content-Type: application/json
private-token: your-gitlab-access-token

4. Custom GitLab Token Header:

Copy & paste β€” that's it
POST http://localhost:3000/mcp
Content-Type: application/json
x-gitlab-token: your-gitlab-access-token

GitLab Instance URL Configuration:

1. GitLab URL Header (Recommended):

Copy & paste β€” that's it
POST http://localhost:3000/mcp
Content-Type: application/json
x-gitlab-url: https://gitlab.company.com

2. Alternative GitLab URL Headers:

Copy & paste β€” that's it
POST http://localhost:3000/mcp
Content-Type: application/json
gitlab-url: https://gitlab.company.com
Copy & paste β€” that's it
POST http://localhost:3000/mcp
Content-Type: application/json
gitlab-api-url: https://gitlab.company.com

5. Fallback to Environment Variables: If no token or URL is provided in headers, the server will fall back to the GITLAB_TOKEN and GITLAB_API_URL environment variables.

Complete Example:

Copy & paste β€” that's it
POST http://localhost:3000/mcp
Content-Type: application/json
Authorization: Bearer your-gitlab-access-token
x-gitlab-url: https://gitlab.company.com

Project Structure

Copy & paste β€” that's it
src/
β”œβ”€β”€ server/
β”‚   └── GitlabMCPServer.ts          # MCP server entry point
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ GitlabAcceptMRTool.ts
β”‚   β”œβ”€β”€ GitlabCreateMRCommentTool.ts
β”‚   β”œβ”€β”€ GitlabGetUserTasksTool.ts
β”‚   β”œβ”€β”€ GitlabRawApiTool.ts
β”‚   β”œβ”€β”€ GitlabSearchProjectDetailsTool.ts
β”‚   β”œβ”€β”€ GitlabSearchUserProjectsTool.ts
β”‚   └── gitlab/
β”‚       β”œβ”€β”€ FieldFilterUtils.ts
β”‚       β”œβ”€β”€ GitlabApiClient.ts
β”‚       └── GitlabApiTypes.ts
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ is.ts
β”‚   └── sensitive.ts
smithery.json                      # Smithery config
USAGE.md                          # Usage examples
package.json
tsconfig.json

Integration

Claude Desktop Client

Stdio Mode (Default)

Add to your config:

Copy & paste β€” that's it
{
  "mcpServers": {
    "@zephyr-mcp/gitlab": {
      "command": "npx",
      "args": ["-y", "@zephyr-mcp/gitlab"]
    }
  }
}

HTTP Stream Mode (Server Deployment)

Server Setup: First start the server (note that both GITLAB_TOKEN and GITLAB_API_URL are optional when using HTTP headers):

Copy & paste β€” that's it
# On your server - no token or URL required in env vars
MCP_TRANSPORT_TYPE=httpStream MCP_PORT=3000 MCP_HOST=0.0.0.0 npx @zephyr-mcp/gitlab

# Or with Docker
docker run -d \
  -p 3000:3000 \
  -e MCP_TRANSPORT_TYPE=httpStream \
  -e MCP_HOST=0.0.0.0 \
  -e MCP_PORT=3000 \
  gitlab-mcp-server

Client Configuration:

Option 1: With Bearer Token (Recommended)

Copy & paste β€” that's it
{
  "mcpServers": {
    "@zephyr-mcp/gitlab": {
      "command": "npx",
      "args": [
        "@modelcontextprotocol/client-cli",
        "http://your-server:3000/mcp",
        "--header", "Authorization: Bearer your-gitlab-access-token"
      ]
    }
  }
}

Option 2: With Private Token Header

Copy & paste β€” that's it
{
  "mcpServers": {
    "@zephyr-mcp/gitlab": {
      "command": "npx",
      "args": [
        "@modelcontextprotocol/client-cli",
        "http://your-server:3000/mcp",
        "--header", "PRIVATE-TOKEN: your-gitlab-access-token"
      ]
    }
  }
}

Option 3: With Dynamic GitLab URL and Token

Copy & paste β€” that's it
{
  "mcpServers": {
    "@zephyr-mcp/gitlab": {
      "command": "npx",
      "args": [
        "@modelcontextprotocol/client-cli",
        "http://your-server:3000/mcp",
        "--header", "Authorization: Bearer your-gitlab-access-token",
        "--header", "x-gitlab-url: https://gitlab.company.com"
      ]
    }
  }
}

Multi-tenant Usage: Each user can configure their own token and GitLab instance URL in their client configuration, allowing the same server instance to serve multiple users with different GitLab permissions and instances.

Smithery

Use directly on Smithery platform:

Copy & paste β€” that's it
smithery add @zephyr-mcp/gitlab

Or search "@zephyr-mcp/gitlab" in Smithery UI and add to your workspace.

Environment variables:

  • GITLAB_API_URL: Base URL of your GitLab API (required for stdio mode, optional for httpStream mode - can be provided via HTTP headers)
  • GITLAB_TOKEN: Access token for GitLab API authentication (required for stdio mode, optional for httpStream mode - can be provided via HTTP headers)
  • MCP_TRANSPORT_TYPE: Transport type (stdio/httpStream)
  • MCP_HOST: Server binding address for HTTP stream mode
  • MCP_PORT: HTTP port for HTTP stream mode
  • MCP_ENDPOINT: HTTP endpoint path for HTTP stream mode

Related Links