gitlab-mcp
gitlab-mcp
用于 GitLab API 的 MCP 服务器。适用于自托管 GitLab 实例和 gitlab.com。
提供用于议题、合并请求、代码审查、流水线、里程碑、发布、搜索和文件访问的工具。
前置要求
Node.js >= 18
npm
具有
api权限范围的 GitLab 个人访问令牌 (Personal Access Token)
Related MCP server: GitLab MCP Server
安装
git clone <repo-url> gitlab-mcp
cd gitlab-mcp
npm install
npm run build配置
在项目根目录下创建 config.json:
{
"token": "glpat-your-token-here",
"apiUrl": "https://your-gitlab-instance.com/api/v4"
}对于 gitlab.com,请使用 "apiUrl": "https://gitlab.com/api/v4" 或完全省略该字段。
或者,设置环境变量而不是使用 config.json:
export GITLAB_PERSONAL_ACCESS_TOKEN="glpat-your-token-here"
export GITLAB_API_URL="https://your-gitlab-instance.com/api/v4"创建 GitLab 令牌
前往 GitLab > 设置 > 访问令牌
创建一个具有
api权限范围的令牌将令牌复制到
config.json中
添加到 Claude Code
将服务器添加到您的 Claude Code MCP 设置中(~/.claude/settings.json 或项目级别的 .claude/settings.local.json):
{
"mcpServers": {
"gitlab": {
"command": "node",
"args": ["/absolute/path/to/gitlab-mcp/index.js"]
}
}
}重启 Claude Code 或运行 /mcp 进行连接。
可用工具
议题 (Issues)
工具 | 描述 |
| 通过项目和 IID 获取单个议题 |
| 列出组内议题,支持过滤(状态、标签、指派人、搜索、里程碑) |
| 列出里程碑中的议题 |
| 创建新议题 |
| 更新议题(状态、标题、描述、标签、指派人、里程碑) |
| 向议题添加评论 |
合并请求 (Merge Requests)
工具 | 描述 |
| 列出合并请求,支持过滤(状态、作者、审查人、指派人、日期、目标分支)。项目为可选参数 — 省略则进行跨项目搜索。 |
| 通过项目和 IID 获取单个合并请求 |
| 获取合并请求的差异 / 变更文件 |
| 列出合并请求上的评论/备注 |
| 向合并请求添加常规评论 |
| 在特定文件和行上创建内联差异评论 |
项目、里程碑、发布
工具 | 描述 |
| 列出组内的项目 |
| 列出组内的里程碑 |
| 列出项目的发布版本 |
搜索与文件
工具 | 描述 |
| 在项目内搜索(代码、议题、合并请求、提交、备注) |
| 从仓库获取文件内容 |
| 列出 CI/CD 流水线,支持过滤(状态、引用) |
通用接口
工具 | 描述 |
| 直接调用任何 GitLab REST API 端点。在没有专用工具时使用。接收 |
示例 — 编辑现有的合并请求备注:
gitlab_api_request({
method: "PUT",
path: "/projects/93/merge_requests/2387/notes/74875",
body: { body: "Updated comment text" }
})Claude Code 中的使用示例
> Review MR !2397 in octopus/reunion/client
Claude will use gitlab_get_merge_request, gitlab_get_mr_changes,
and gitlab_create_mr_discussion to review and leave inline comments.开发
# Edit index.ts, then rebuild
npm run build
# Reconnect in Claude Code
/mcpThis server cannot be deployed
Maintenance
Related MCP Connectors
GitLab MCP — wraps the GitLab REST API v4 (BYO API key)
Go MCP server for GitLab: 2 dynamic tools reach 1000+ REST/GraphQL actions. Free/CE, no paid tier.
A MCP server built for developers enabling Git based project management with project and personal…
Related MCP Servers
- -licenseAqualityAmaintenanceMCP Server for the GitLab API, enabling project management, file operations, and more.93,856 npm90,399MIT
- FlicenseNot gradedqualityCmaintenanceAn MCP server for the GitLab API that enables comprehensive project management, file operations, and issue tracking. It supports automated branch creation, batch file pushes, and interaction with merge requests and CI/CD logs.-
- AlicenseNot gradedqualityBmaintenanceMCP server for the GitLab REST API providing tools to manage projects, merge requests, pipelines, CI/CD variables, approvals, issues, and code reviews.933 PyPI6MIT
- FlicenseBqualityDmaintenanceProvides tools to interact with a self-hosted GitLab instance, enabling project, issue, note, search, todo, and wiki page management through MCP.161-