/ 目錄 / 演練場 / 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