Skip to main content
Glama

GitLab MCP Server

Official

GitLab MCP 服务器

GitLab API 的 MCP 服务器,支持项目管理、文件操作等。

特征

  • 自动创建分支:创建/更新文件或推送更改时,如果分支不存在,则会自动创建分支
  • 全面的错误处理:针对常见问题的清晰错误消息
  • Git 历史记录保存:操作无需强制推送即可维护正确的 Git 历史记录
  • 批量操作:支持单文件和多文件操作

工具

  1. create_or_update_file
    • 创建或更新项目中的单个文件
    • 输入:
      • project_id (字符串):项目 ID 或 URL 编码路径
      • file_path (字符串):创建/更新文件的路径
      • content (字符串):文件的内容
      • commit_message (字符串):提交消息
      • branch (字符串):创建/更新文件的分支
      • previous_path (可选字符串):要移动/重命名的文件的路径
    • 返回:文件内容和提交详细信息
  2. push_files
    • 在一次提交中推送多个文件
    • 输入:
      • project_id (字符串):项目 ID 或 URL 编码路径
      • branch (字符串):要推送到的分支
      • files (数组):要推送的文件,每个文件都有file_pathcontent
      • commit_message (字符串):提交消息
    • 返回:更新的分支参考
  3. search_repositories
    • 搜索 GitLab 项目
    • 输入:
      • search (字符串):搜索查询
      • page (可选数字):分页的页码
      • per_page (可选数字):每页结果数(默认 20)
    • 返回:项目搜索结果
  4. create_repository
    • 创建新的 GitLab 项目
    • 输入:
      • name (字符串):项目名称
      • description (可选字符串):项目描述
      • visibility (可选字符串):“private”、“internal”或“public”
      • initialize_with_readme (可选布尔值): 使用 README 初始化
    • 返回:创建的项目详细信息
  5. get_file_contents
    • 获取文件或目录的内容
    • 输入:
      • project_id (字符串):项目 ID 或 URL 编码路径
      • file_path (字符串):文件/目录的路径
      • ref (可选字符串):从中获取内容的分支/标签/提交
    • 返回:文件/目录内容
  6. create_issue
    • 创建新问题
    • 输入:
      • project_id (字符串):项目 ID 或 URL 编码路径
      • title (字符串):问题标题
      • description (可选字符串):问题描述
      • assignee_ids (可选数字[]):要分配的用户 ID
      • labels (可选字符串[]):要添加的标签
      • milestone_id (可选数字):里程碑 ID
    • 返回:创建问题详情
  7. create_merge_request
    • 创建新的合并请求
    • 输入:
      • project_id (字符串):项目 ID 或 URL 编码路径
      • title (字符串):MR 标题
      • description (可选字符串):MR 描述
      • source_branch (字符串):包含更改的分支
      • target_branch (字符串):要合并的分支
      • draft (可选布尔值):创建为 MR 草稿
      • allow_collaboration (可选布尔值):允许上游成员提交
    • 返回:创建的合并请求详细信息
  8. fork_repository
    • 派生一个项目
    • 输入:
      • project_id (字符串):项目 ID 或 URL 编码路径
      • namespace (可选字符串):要分叉到的命名空间
    • 返回:分叉项目详细信息
  9. create_branch
    • 创建新分支
    • 输入:
      • project_id (字符串):项目 ID 或 URL 编码路径
      • branch (字符串):新分支的名称
      • ref (可选字符串):新分支的源分支/提交
    • 返回:创建的分支引用

设置

个人访问令牌

创建具有适当权限的 GitLab 个人访问令牌

  • 前往 GitLab 中的“用户设置”>“访问令牌”
  • 选择所需的范围:
    • api用于完整 API 访问
    • read_api用于只读访问
    • read_repositorywrite_repository用于存储库操作
  • 创建令牌并安全保存

与 Claude Desktop 一起使用

将以下内容添加到您的claude_desktop_config.json中:

Docker
{ "mcpServers": { "gitlab": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "GITLAB_PERSONAL_ACCESS_TOKEN", "-e", "GITLAB_API_URL", "mcp/gitlab" ], "env": { "GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>", "GITLAB_API_URL": "https://gitlab.com/api/v4" // Optional, for self-hosted instances } } } }
NPX
{ "mcpServers": { "gitlab": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-gitlab" ], "env": { "GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>", "GITLAB_API_URL": "https://gitlab.com/api/v4" // Optional, for self-hosted instances } } } }

与 VS Code 一起使用

为了快速安装,请使用下面的一键安装按钮之一...

如需手动安装,请将以下 JSON 块添加到 VS Code 中的“用户设置 (JSON)”文件中。您可以按下Ctrl + Shift + P并输入Preferences: Open User Settings (JSON)来执行此操作。

或者,您可以将其添加到工作区中名为.vscode/mcp.json的文件中。这样您就可以与其他人共享该配置。

请注意.vscode/mcp.json文件中不需要mcp键。

Docker
{ "mcp": { "inputs": [ { "type": "promptString", "id": "gitlab_token", "description": "GitLab Personal Access Token", "password": true }, { "type": "promptString", "id": "gitlab_url", "description": "GitLab API URL (optional)", "default": "https://gitlab.com/api/v4" } ], "servers": { "gitlab": { "command": "docker", "args": [ "run", "--rm", "-i", "mcp/gitlab" ], "env": { "GITLAB_PERSONAL_ACCESS_TOKEN": "${input:gitlab_token}", "GITLAB_API_URL": "${input:gitlab_url}" } } } } }
NPX
{ "mcp": { "inputs": [ { "type": "promptString", "id": "gitlab_token", "description": "GitLab Personal Access Token", "password": true }, { "type": "promptString", "id": "gitlab_url", "description": "GitLab API URL (optional)", "default": "https://gitlab.com/api/v4" } ], "servers": { "gitlab": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-gitlab" ], "env": { "GITLAB_PERSONAL_ACCESS_TOKEN": "${input:gitlab_token}", "GITLAB_API_URL": "${input:gitlab_url}" } } } } }

建造

Docker 构建:

docker build -t vonwig/gitlab:mcp -f src/gitlab/Dockerfile .

环境变量

  • GITLAB_PERSONAL_ACCESS_TOKEN :您的 GitLab 个人访问令牌(必需)
  • GITLAB_API_URL :GitLab API 的基本 URL(可选,默认为https://gitlab.com/api/v4

执照

此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。

Deploy Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

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.

GitLab API 的 MCP 服务器,支持项目管理、文件操作等。

  1. 特征
    1. 工具
      1. 设置
        1. 个人访问令牌
        2. 与 Claude Desktop 一起使用
        3. 与 VS Code 一起使用
      2. 建造
        1. 环境变量
          1. 执照

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              MCP Server for the GitHub API, enabling file operations, repository management, search functionality, and more.
              Last updated -
              22,573
              68,255
              MIT License
            • A
              security
              F
              license
              A
              quality
              MCP Server for the GitHub API, providing features for file operations, repository management, and advanced search, with automatic branch creation and comprehensive error handling.
              Last updated -
              18
              0
              4
              • Linux
              • Apple
            • A
              security
              A
              license
              A
              quality
              GitLab MCP Server (with activity tracking and group projects listing features) This server is based on the original GitLab MCP server with Group Projects Listing and Activity Tracking enhancements
              Last updated -
              28
              86
              27
              MIT License
            • -
              security
              A
              license
              -
              quality
              An MCP server that enables communication with GitLab repositories, allowing interaction with GitLab's API to manage projects, issues, and repositories through natural language.
              Last updated -
              7,512
              1
              MIT License

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/modelcontextprotocol/gitlab'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server