Enables management of GitLab pipelines including triggering pipelines, checking status, listing pipelines, retrieving pipeline jobs, and canceling pipelines through GitLab's API
GitLab Pipeline MCP Server
一个用于 GitLab 流水线操作的 Model Context Protocol (MCP) 服务器。
🎯 项目概述
本项目允许AI客户端(如Cursor、Claude Desktop等)通过自然语言直接操作GitLab流水线。
功能特性
- 🚀 触发 GitLab 流水线
- 📊 获取流水线状态
- 📋 列出流水线
- 🔧 获取流水线作业
- ❌ 取消流水线
安装
环境变量配置
在使用前,请设置以下环境变量:
或者创建 .env
文件:
使用方式
1. STDIO 模式(标准输入输出)
适用于 MCP 客户端直接连接:
MCP 客户端配置示例:
2. Streamable HTTP 模式
适用于开发和调试,支持 HTTP 端点访问:
MCP 客户端配置示例:
HTTP 端点:
- 🔗 MCP 端点:
http://localhost:3300/mcp
- 💚 健康检查:
http://localhost:3300/health
- 📋 服务信息:
http://localhost:3300/
🔧 使用MCP Inspector调试
这将打开一个Web界面(通常在 http://localhost:5173),你可以在其中:
- 查看所有可用工具
- 测试工具调用
- 查看请求和响应
- 调试参数传递
🛠️ 核心功能
动态参数支持
所有工具都支持动态传入以下参数,无需预先配置:
- gitlabUrl: GitLab基础URL(如:
https://gitlab.com
) - projectId: 项目ID或路径(如:
123
或group/project
) - token: GitLab访问令牌(如:
glpat-xxxxxxxxxxxx
)
可用工具列表
工具名称 | 功能描述 | 主要参数 |
---|---|---|
trigger_pipeline | 触发流水线 | gitlabUrl, projectId, ref, token, variables(可选) |
get_pipeline_status | 获取流水线状态 | gitlabUrl, projectId, pipelineId, token |
list_pipelines | 列出流水线 | gitlabUrl, projectId, token, ref(可选), status(可选) |
get_pipeline_jobs | 获取流水线作业 | gitlabUrl, projectId, pipelineId, token |
cancel_pipeline | 取消流水线 | gitlabUrl, projectId, pipelineId, token |
💬 使用示例
在支持MCP的AI客户端中,你可以使用自然语言来操作GitLab流水线:
基础操作
高级操作
多环境支持
🔐 安全配置
GitLab访问令牌
- 登录GitLab
- 进入 Settings > Access Tokens
- 创建新令牌,需要以下权限:
api
- 完整API访问权限read_repository
- 读取仓库权限write_repository
- 写入仓库权限
环境变量安全
- 永远不要将
.env
文件提交到版本控制 - 使用不同的令牌用于不同的环境
- 定期轮换访问令牌
- 限制令牌的权限范围
📁 项目结构
🐛 常见问题
Q: 服务器启动失败
A: 检查Node.js版本(需要>=18),确保依赖已安装,检查TypeScript编译错误。
Q: GitLab API调用失败
A: 验证访问令牌权限,检查GitLab URL格式,确认项目ID正确。
Q: MCP客户端连接不上
A: 检查配置文件路径,确认服务器已构建,查看客户端日志。
Q: 工具调用参数错误
A: 参考工具定义中的参数要求,使用MCP Inspector测试参数格式。
📚 相关资源
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables AI clients to manage GitLab pipelines through natural language commands. Supports triggering pipelines, checking status, listing pipelines, viewing jobs, and canceling pipelines across multiple GitLab instances.
Related MCP Servers
- -securityFlicense-qualityA custom server implementation that allows AI assistants to interact with GitLab repositories, providing capabilities for searching, fetching files, creating/updating content, and managing issues and merge requests.Last updated -1JavaScript
- AsecurityFlicenseAqualityEnables comprehensive GitHub operations through natural language including file management, repository administration, issue tracking, and advanced code searching.Last updated -4711TypeScript
- -securityFlicense-qualityProvides GitLab integration for AI assistants using Model Context Protocol, enabling repository operations, file management, issue tracking, merge requests, and branch/tag administration through natural language.Last updated -2Python
- -securityFlicense-qualityConnects AI assistants to GitLab, allowing users to manage merge requests, view reviews, and interact with discussions through natural language queries.Last updated -8Python