MCP-GitLab管理器
一种模型上下文协议服务器,通过自然语言与GitLab账户进行交互,以管理仓库、合并请求、代码审查和CI/CD管道。
可用工具 (41 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
gitlab_list_projects 4 个参数
List GitLab projects accessible to the user
该工具无需必填参数,直接调用即可
gitlab_get_project 1 个参数 需填 1 项
Get details of a specific GitLab project
必填参数:project_id
gitlab_list_branches 2 个参数 需填 1 项
List branches of a GitLab project
必填参数:project_id
gitlab_list_merge_requests 3 个参数 需填 1 项
List merge requests in a GitLab project
必填参数:project_id
gitlab_get_merge_request 2 个参数 需填 2 项
Get details of a specific merge request
必填参数:project_id、merge_request_iid
gitlab_get_merge_request_changes 2 个参数 需填 2 项
Get changes (diff) of a specific merge request
必填参数:project_id、merge_request_iid
gitlab_create_merge_request_note 3 个参数 需填 3 项
Add a comment to a merge request
必填参数:project_id、merge_request_iid、body
gitlab_create_merge_request_note_internal 4 个参数 需填 3 项
Add a comment to a merge request with option to make it an internal note
必填参数:project_id、merge_request_iid、body
gitlab_update_merge_request 4 个参数 需填 2 项
Update a merge request title and description
必填参数:project_id、merge_request_iid
gitlab_list_issues 3 个参数 需填 1 项
List issues in a GitLab project
必填参数:project_id
gitlab_get_repository_file 3 个参数 需填 2 项
Get content of a file in a repository
必填参数:project_id、file_path
gitlab_compare_branches 3 个参数 需填 3 项
Compare branches, tags or commits
必填参数:project_id、from、to
gitlab_list_integrations 1 个参数 需填 1 项
List all available project integrations/services
必填参数:project_id
gitlab_get_integration 2 个参数 需填 2 项
Get integration details for a project
必填参数:project_id、integration
gitlab_update_slack_integration 4 个参数 需填 2 项
Update Slack integration settings for a project
必填参数:project_id、webhook
gitlab_disable_slack_integration 1 个参数 需填 1 项
Disable Slack integration for a project
必填参数:project_id
gitlab_list_webhooks 1 个参数 需填 1 项
List webhooks for a project
必填参数:project_id
gitlab_get_webhook 2 个参数 需填 2 项
Get details of a specific webhook
必填参数:project_id、webhook_id
gitlab_add_webhook 7 个参数 需填 2 项
Add a new webhook to a project
必填参数:project_id、url
gitlab_update_webhook 8 个参数 需填 3 项
Update an existing webhook
必填参数:project_id、webhook_id、url
gitlab_delete_webhook 2 个参数 需填 2 项
Delete a webhook
必填参数:project_id、webhook_id
gitlab_test_webhook 2 个参数 需填 2 项
Test a webhook
必填参数:project_id、webhook_id
gitlab_list_trigger_tokens 1 个参数 需填 1 项
List pipeline trigger tokens
必填参数:project_id
gitlab_get_trigger_token 2 个参数 需填 2 项
Get details of a pipeline trigger token
必填参数:project_id、trigger_id
gitlab_create_trigger_token 2 个参数 需填 2 项
Create a new pipeline trigger token
必填参数:project_id、description
gitlab_update_trigger_token 3 个参数 需填 3 项
Update a pipeline trigger token
必填参数:project_id、trigger_id、description
gitlab_delete_trigger_token 2 个参数 需填 2 项
Delete a pipeline trigger token
必填参数:project_id、trigger_id
gitlab_trigger_pipeline 4 个参数 需填 3 项
Trigger a pipeline run
必填参数:project_id、ref、token
gitlab_list_cicd_variables 1 个参数 需填 1 项
List CI/CD variables for a project
必填参数:project_id
gitlab_get_cicd_variable 2 个参数 需填 2 项
Get a specific CI/CD variable
必填参数:project_id、key
gitlab_create_cicd_variable 5 个参数 需填 3 项
Create a new CI/CD variable
必填参数:project_id、key、value
gitlab_update_cicd_variable 5 个参数 需填 3 项
Update a CI/CD variable
必填参数:project_id、key、value
gitlab_delete_cicd_variable 2 个参数 需填 2 项
Delete a CI/CD variable
必填参数:project_id、key
gitlab_list_users 2 个参数
List GitLab users
该工具无需必填参数,直接调用即可
gitlab_get_user 1 个参数 需填 1 项
Get details of a specific user
必填参数:user_id
gitlab_list_groups 2 个参数
List GitLab groups
该工具无需必填参数,直接调用即可
gitlab_get_group 1 个参数 需填 1 项
Get details of a specific group
必填参数:group_id
gitlab_list_group_members 1 个参数 需填 1 项
List members of a group
必填参数:group_id
gitlab_add_group_member 3 个参数 需填 3 项
Add a user to a group
必填参数:group_id、user_id、access_level
gitlab_list_project_members 1 个参数 需填 1 项
List members of a project
必填参数:project_id
gitlab_add_project_member 3 个参数 需填 3 项
Add a user to a project
必填参数:project_id、user_id、access_level
服务介绍
GitLab MCP 服务器
这是一个模型上下文协议 (MCP) 服务器,它使您能够与您的 GitLab 账户进行交互。获取差异、分析合并请求、审查代码、挑选更改等。这是从 Model Context Protocol 项目中的 MCP GitLab 服务器 扩展而来的版本。
功能
此 MCP 服务器提供了与 GitLab 仓库互动的全面工具,包括:
核心仓库功能
- 列出项目并检索详细信息
- 管理分支和仓库
- 处理合并请求和差异
- 向合并请求添加评论和内部注释
- 更新合并请求属性
- 列出和处理问题
- 获取和比较仓库文件内容
项目设置与集成
- 管理项目集成和服务
- 配置和控制 Slack 集成
- 设置、更新和测试 Webhook
CI/CD 管理
- 处理管道触发令牌
- 管理 CI/CD 变量
- 触发和控制管道
用户与组管理
- 列出和管理用户
- 处理组和组成员资格
- 管理项目成员和访问级别
安装
先决条件
- Node.js(v16 或更高版本)
- npm
- 一个带有 API 令牌的 GitLab 账户
设置
- 克隆仓库:
git clone https://github.com/rifqi96/mcp-gitlab.git
cd mcp-gitlab
- 安装依赖项:
npm install
- 构建服务器:
npm run build
- 安装 git 钩子(可选,但推荐给贡献者):
npm run install-hooks
这将安装一个 pre-commit 钩子,当 src/utils/tools-data.ts 发生变化时自动重新生成 TOOLS.md。
- 配置您的 GitLab API 令牌:
您需要在 MCP 设置配置文件中提供您的 GitLab API 令牌。该令牌用于与 GitLab API 进行身份验证。
对于 Cursor/Roo Cline,在您的 MCP 设置文件 (~/Library/Application Support/Cursor/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json) 中添加以下内容:
{
"mcpServers": {
"gitlab": {
"command": "node",
"args": [
"/path/to/mcp-gitlab/build/index.js"
],
"env": {
"GITLAB_API_TOKEN": "YOUR_GITLAB_API_TOKEN",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
}
}
}
对于 Claude Desktop,在您的 MCP 设置文件 (~/Library/Application Support/Claude/claude_desktop_config.json) 中添加以下内容:
{
"mcpServers": {
"gitlab": {
"command": "node",
"args": [
"/path/to/mcp-gitlab/build/index.js"
],
"env": {
"GITLAB_API_TOKEN": "YOUR_GITLAB_API_TOKEN",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
}
}
}
将 YOUR_GITLAB_API_TOKEN 替换为您的实际 GitLab API 令牌。您可以在您的 GitLab 账户下的设置 > 访问令牌中生成一个令牌。
可用工具
有关可用工具及其参数的完整列表,请参阅 TOOLS.md。
示例用法
这里是一些如何使用这些工具的例子,这些工具支持 MCP 的 AI 助手:
列出您的项目
Could you list my GitLab projects?
获取特定合并请求的信息
Can you show me the details of merge request with ID 123 in the project 'mygroup/myproject'?
向合并请求添加评论
Please add a comment to merge request 123 in project 'mygroup/myproject' saying "This looks good, but please add more tests."
向合并请求添加内部注释
Add an internal note to merge request 123 in project 'mygroup/myproject' that says "Needs security review before merging." Make sure it's only visible to team members.
更新合并请求的标题和描述
Update the title of merge request 123 in project 'mygroup/myproject' to "Fix login page performance issues" and update the description to include "This PR addresses the slow loading times on the login page by optimizing database queries."
比较分支
Compare the 'feature-branch' with 'main' in the project 'mygroup/myproject' and show me the differences.
实用工作流程
审查合并请求
1. Show me merge request 123 in project 'mygroup/myproject'
2. Show me the changes for this merge request
3. Add an internal note with my review comments
4. Update the merge request title to better reflect the changes
项目探索
1. List all my GitLab projects
2. Show me the details of project 'mygroup/myproject'
3. List all branches in this project
4. Show me the content of the README.md file in the main branch
可用资源
gitlab://projects
使用您的 API 令牌可访问的 GitLab 项目列表。
与 AI 助手集成
GitLab MCP 服务器与支持模型上下文协议 (MCP) 的 AI 助手集成。
功能
当连接到 AI 助手时,此服务器使助手能够:
- 查看和分析代码:助手可以获取文件内容、查看分支差异并检查合并请求更改以更好地理解代码。
- 提供代码审查:助手可以分析合并请求并通过评论或内部笔记提供反馈。
- 管理项目工作流程:助手可以更新合并请求属性、添加评论并帮助完成仓库管理工作任务。
- 探索项目结构:助手可以浏览项目、分支和文件以了解代码库结构。
- 配置 CI/CD 和集成:助手可以帮助设置 Webhook、管理 CI/CD 变量并配置项目集成。
充分利用 AI 助手集成
- 在询问有关项目、合并请求或文件的问题时要具体明确
- 尽可能提供项目 ID 或路径
- 通过让助手分析特定的合并请求来进行代码审查
- 让助手帮助进行仓库配置和管理工作任务
- 使用内部笔记为团队成员提供仅限团队的合并请求反馈
许可证
MIT