/ 目录 / 演练场 / GitLab MCP
● 社区 zereight 🔑 需要你的密钥

GitLab MCP

作者 zereight · zereight/gitlab-mcp

Treat GitLab like the GitHub MCP treats GitHub — issues, MRs, pipelines, comments — with explicit support for self-hosted instances.

Zereight's GitLab MCP is the de-facto community implementation. It covers REST and a curated GraphQL surface, supports self-hosted GitLab via GITLAB_API_URL, and has fine-grained read/write tool gating.

为什么要用

核心特性

实时演示

实际使用效果

就绪

安装

选择你的客户端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "gitlab-mcp-zereight": {
      "command": "npx",
      "args": [
        "-y",
        "@zereight/mcp-gitlab"
      ],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "${GITLAB_TOKEN}",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

打开 Claude Desktop → Settings → Developer → Edit Config。保存后重启应用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "gitlab-mcp-zereight": {
      "command": "npx",
      "args": [
        "-y",
        "@zereight/mcp-gitlab"
      ],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "${GITLAB_TOKEN}",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

Cursor 使用与 Claude Desktop 相同的 mcpServers 格式。项目级配置优先于全局。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "gitlab-mcp-zereight": {
      "command": "npx",
      "args": [
        "-y",
        "@zereight/mcp-gitlab"
      ],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "${GITLAB_TOKEN}",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

点击 Cline 侧栏中的 MCP Servers 图标,然后选 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "gitlab-mcp-zereight": {
      "command": "npx",
      "args": [
        "-y",
        "@zereight/mcp-gitlab"
      ],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "${GITLAB_TOKEN}",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

格式与 Claude Desktop 相同。重启 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "gitlab-mcp-zereight",
      "command": "npx",
      "args": [
        "-y",
        "@zereight/mcp-gitlab"
      ]
    }
  ]
}

Continue 使用服务器对象数组,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "gitlab-mcp-zereight": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "@zereight/mcp-gitlab"
        ]
      }
    }
  }
}

加入 context_servers。Zed 保存后热重载。

claude mcp add gitlab-mcp-zereight -- npx -y @zereight/mcp-gitlab

一行命令搞定。用 claude mcp list 验证,claude mcp remove 卸载。

使用场景

实战用法: GitLab MCP

Review an MR end-to-end from Claude

👤 Developers ⏱ ~15 min intermediate

何时使用: You want a quick triage pass on a teammate's MR before opening the GitLab UI.

步骤
  1. Get MR
    Fetch MR by IID; pull title, description, diffs.✓ 已复制
    → Diff loaded
  2. Inspect pipeline
    List pipelines for this MR; report failures.✓ 已复制
    → Pipeline status known
  3. Comment
    Post inline comments for the issues you found.✓ 已复制
    → Comments visible in UI

结果: MR review done without leaving Claude; comments posted under your account.

Triage failing pipelines across projects

👤 Developers ⏱ ~15 min intermediate

何时使用: CI is red across several projects and you want a unified view.

步骤
  1. List failed
    list_pipelines status=failed across group X.✓ 已复制
    → Failed pipelines listed
  2. Pull logs
    For each, fetch the failing job log tail.✓ 已复制
    → Top error per pipeline
  3. Cluster
    Group by error signature; identify the shared cause.✓ 已复制
    → One root-cause summary

结果: You know whether it's one infra issue or N independent failures.

组合

与其他 MCP 搭配,撬动十倍杠杆

gitlab-mcp-zereight + linear

Cross-link Linear issues to GitLab MRs in PR descriptions

Combine gitlab-mcp-zereight with linear: Cross-link Linear issues to GitLab MRs in PR descriptions✓ 已复制

工具

此 MCP 暴露的能力

工具输入参数何时调用成本
list_issues (see docs) List issues with filters 1 call
get_merge_request (see docs) Fetch MR details + diffs 1 call
create_merge_request (see docs) Open a new MR 1 call
list_pipelines (see docs) List CI pipelines 1 call
retry_pipeline (see docs) Retry a failed pipeline 1 call
add_comment (see docs) Post issue/MR comment 1 call

成本与限制

运行它的成本

API 配额
GitLab API rate limits (varies by instance)
每次调用 Token 数
MR diffs can be huge — paginate
费用
Free; your GitLab plan applies
提示
Use read-only mode for any agent that doesn't need to write

安全

权限、密钥、影响范围

最小权限: api read_repository (scoped PAT)
凭据存储: PAT in env var
数据出站: Your GitLab API URL only
切勿授予: use sudo scope unless you know why

故障排查

常见错误与修复

401 on self-hosted

Set GITLAB_API_URL to the full /api/v4 URL of your instance

Rate limited

Use a project-scoped PAT; lower polling cadence

替代方案

GitLab MCP 对比其他方案

替代方案何时用它替代权衡
Official GitLab MCPOnce GitLab ships first-partyNot yet GA
github-mcp-serverYou're on GitHubDifferent platform

更多

资源

📖 阅读 GitHub 上的官方 README

🐙 查看未解决的 issue

🔍 浏览全部 400+ MCP 服务器和 Skills