GitLab MCP Server

by rifqi96
Verified

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.

Integrations

  • Provides comprehensive tools for interacting with GitLab repositories, including managing projects, branches, merge requests, issues, code review, CI/CD pipelines, webhooks, and user/group administration.

  • Enables configuration and control of Slack integration with GitLab projects.

GitLab MCP 服务器

模型上下文协议 (MCP) 服务器,可让您与 GitLab 帐户进行交互。您可以获取差异、分析合并请求、审查代码、挑选更改等等。这是模型上下文协议项目中MCP GitLab 服务器的扩展版本。

特征

该 MCP 服务器提供了与 GitLab 存储库交互的综合工具,包括:

核心存储库功能

  • 列出项目并检索详细信息
  • 管理分支和存储库
  • 处理合并请求和差异
  • 向合并请求添加评论和内部注释
  • 更新合并请求属性
  • 列出并处理问题
  • 获取并比较存储库文件内容

项目设置和集成

  • 管理项目集成和服务
  • 配置和控制 Slack 集成
  • 设置、更新和测试 webhook

CI/CD 管理

  • 使用管道触发器令牌
  • 管理 CI/CD 变量
  • 触发和控制管道

用户和组管理

  • 列出和管理用户
  • 使用群组和群组成员资格
  • 管理项目成员和访问级别

安装

先决条件

  • Node.js(v16 或更高版本)
  • npm
  • 具有 API 令牌的 GitLab 帐户

设置

  1. 克隆存储库:
git clone https://github.com/rifqi96/mcp-gitlab.git cd mcp-gitlab
  1. 安装依赖项:
npm install
  1. 构建服务器:
npm run build
  1. 安装 git hooks(可选,但建议贡献者安装):
npm run install-hooks

这将安装一个预提交钩子,当 src/utils/tools-data.ts 发生变化时,它会自动重新生成 TOOLS.md。

  1. 配置您的 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 项目列表。

与人工智能助手集成

GitLab MCP 服务器与支持模型上下文协议 (MCP) 的 AI 助手集成。

功能

当连接到 AI 助手时,该服务器可使助手能够:

  1. 查看和分析代码:助手可以获取文件内容、查看分支差异并检查合并请求更改,以便更好地理解代码。
  2. 提供代码审查:助手可以分析合并请求并通过评论或内部注释提供反馈。
  3. 管理项目工作流程:助手可以更新合并请求属性、添加评论并协助完成存储库管理任务。
  4. 探索项目结构:助手可以浏览项目、分支和文件以了解代码库结构。
  5. 配置 CI/CD 和集成:该助手可以帮助设置 webhook、管理 CI/CD 变量以及配置项目集成。

充分利用人工智能助手集成

  • 询问项目、合并请求或文件时要具体
  • 尽可能提供项目 ID 或路径
  • 使用助手进行代码审查,要求它分析特定的合并请求
  • 让助手协助完成存储库配置和管理任务
  • 使用内部注释对合并请求进行团队专属反馈

执照

麻省理工学院

ID: 7phkmkcd67