连接器指南阅读约 7 分钟39 个 MCP 工具7 种语言

如何通过 MCP 将 GitLab 连接到 Gemini

让你的 AI 在 GitLab 中工作:查找项目,分拣和更新议题(issue),审阅合并请求(merge request)及其差异和评论,检查流水线并阅读失败作业的日志,以及读取分支、提交和文件。支持 GitLab.com 或你自己的 GitLab 实例,使用个人访问令牌。

HC作者:HelpCode 团队更新于 7 分钟阅读 在 GitHub 开源

无需信用卡 · 7 天试用 · 提供自托管方案

GitLab

GitLab

Let your AI work in GitLab: find projects, triage and update issues, review merge requests with their diffs and comments, check pipelines and read failing job logs, and read branches, commits and files. GitLab.com or your own GitLab instance, with a personal access token.

个工具

39

区域

INTL

类别

基础设施

身份验证

Bearer Token

所需环境变量

GITLAB_URLGITLAB_TOKEN
在 Cloud 上一键安装

7 天免费试用 · 无需信用卡

  • 7 天免费试用
    无需信用卡
  • 符合 GDPR,SOC 2 就绪
    数据驻留欧盟,审计日志
  • 在 GitHub 开源
    开源 · AGPL-3.0
  • 支持 ChatGPT、Claude、Gemini
    任何兼容 MCP 的客户端

跳过安装。2 分钟内即可运行。

在 cloud.anythingmcp.com 开始免费试用,一键添加 GitLab,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。

开始免费试用

摘要

让你的 AI 在 GitLab 中工作:查找项目,分拣和更新议题(issue),审阅合并请求(merge request)及其差异和评论,检查流水线并阅读失败作业的日志,以及读取分支、提交和文件。支持 GitLab.com 或你自己的 GitLab 实例,使用个人访问令牌。

试试这样问

GitLab 的示例提示

点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。

GitLab · 通过 MCP 实时
分享
Opus 4.7

Claude 是 AI,可能会出错。请核对回答。

💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → GitLab、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无 git clone、无本地服务器。

GitLab + Gemini

让你的 AI 在 GitLab 中工作:查找项目,分拣和更新议题(issue),审阅合并请求(merge request)及其差异和评论,检查流水线并阅读失败作业的日志,以及读取分支、提交和文件。支持 GitLab.com 或你自己的 GitLab 实例,使用个人访问令牌。

前提条件

完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:

GITLAB_URL, GITLAB_TOKEN

步骤 1 — 获取凭证

  1. 在 GitLab 中点击你的头像 → Edit profile → Access → Personal access tokens → Generate token。在 GitLab.com 上,该页面位于 gitlab.com/-/user_settings/personal_access_tokens。
  2. 为令牌命名(例如 "AnythingMCP"),设置过期日期(GitLab.com 上最长 365 天),并勾选权限范围 api。如需只读设置,请改为勾选 read_api。
  3. 立即复制令牌:GitLab 只显示一次。令牌以 glpat- 开头。
  4. 把令牌填入 GITLAB_TOKEN,不要带 Bearer 字样。将 GITLAB_URL 设为 https://gitlab.com(GitLab.com),或设为你的 Self-Managed 或 Dedicated 实例在浏览器中打开时的地址(例如 https://gitlab.example.com),不要带 /api/v4,末尾也不要加斜杠。然后安装连接器。
  5. 先运行 gitlab_get_current_user:它会显示该令牌属于哪个 GitLab 用户,并确认地址正确。然后用路径把项目告诉 AI,例如 my-group/my-project,或者让它用 gitlab_list_projects 查找。

令牌有效期和访问范围:GitLab.com 上的令牌最长有效 365 天。过期后,用相同的权限范围生成新令牌,再次填入 GITLAB_TOKEN。连接器以令牌所属用户的身份操作:AI 能看到和修改的正是该用户有权限的内容。fine-grained 个人访问令牌(GitLab 19.2 及以上)用法相同:为相关项目的 issues、merge requests、仓库、流水线和作业授予读写权限。GitLab.com 上有些群组强制要求 fine-grained 令牌,此时传统令牌在它们的项目上会报错 "Access denied: This operation requires a fine-grained personal access token"。项目访问令牌和群组访问令牌也可以使用,但在 GitLab.com 上需要 Premium 或 Ultimate。

只读设置:使用带 read_api 的令牌,并关闭 gitlab_create_issue, gitlab_update_issue, gitlab_add_issue_note, gitlab_create_merge_request, gitlab_update_merge_request, gitlab_add_merge_request_note 和 gitlab_create_branch。

安装时默认关闭:gitlab_delete_issue(永久删除议题,只有项目所有者和管理员可以执行,通常用 gitlab_update_issue 关闭议题才是你想要的)和 gitlab_delete_branch。只有在 AI 需要删除议题或分支时才打开它们。

项目、议题和合并请求:工具通过数字 id 或完整路径(例如 my-group/my-project)接收项目。议题和合并请求用 GitLab 中显示的编号(#42、!17)指定,而不是全局 id。gitlab_list_project_members 提供指派人和审阅人的用户 id。gitlab_list_my_issues 和 gitlab_list_my_merge_requests 跨所有项目工作,默认显示令牌所属用户自己的条目,包括等待其审阅的合并请求。

审阅、流水线和代码:审阅合并请求时,AI 先读取 gitlab_get_merge_request(合并状态和冲突),再逐页读取 gitlab_get_merge_request_diffs,以及 gitlab_list_merge_request_commits 和 gitlab_list_merge_request_notes。差异过大的文件返回时不带文本;AI 会改用 gitlab_get_file_content 在源分支上读取。排查失败的流水线时,它从 gitlab_list_pipelines 到 gitlab_list_pipeline_jobs(只看失败的作业),再到 gitlab_get_job_log。文件和作业日志在 200 KB 处截断,保留开头部分:更长的日志请在 GitLab 中打开。gitlab_search_project 在任何方案下都能搜索单个项目内的代码;用 gitlab_search 在整个实例范围内搜索代码需要 advanced search,这是 Premium 功能。

写入前先确认:议题、评论、合并请求和分支都以令牌所属用户的名义创建。AI 会先给你看标题、正文或分支,等你确认后再写入。评论中的快捷操作(quick actions),例如 /label、/assign、/close、/approve 或 /merge,会由 GitLab 执行,因此 AI 只在你要求时才加入。创建分支需要 Developer 权限。

速率限制:GitLab.com 允许每个用户每分钟约 2,000 次 API 请求、200 个新议题和 60 条新评论,以及每分钟 100 次搜索。Self-Managed 实例的限制由管理员设置。超出限制时 GitLab 返回 429:稍等后再试。

常见错误:401 表示令牌错误、已过期或已被撤销,或者 GITLAB_URL 指向的不是签发该令牌的实例。403 表示缺少权限范围(例如用 read_api 令牌执行写入),或该用户的角色不足以执行此操作。404 表示项目、议题或文件不存在,或该用户看不到它:GitLab 会用 404 隐藏私有资源。400 会指出缺失或无效的字段。新建合并请求时返回 409,表示这两个分支之间已有一个打开的合并请求。已改名的项目在旧路径下仍可读取,但在旧路径上写入会返回 405:请使用新路径或数字 id。

连接器没有用于合并或批准合并请求、推送提交、编辑文件,以及运行、重试或取消流水线的工具,也不涉及 CI/CD 变量、发布(releases)、Wiki、软件包、容器镜像库和管理功能。

步骤 2 — 安装 adapter

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

步骤 3 — 在 Gemini 中添加连接器

你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(https://cloud.anythingmcp.com/mcp/…)。本指南中出现 YOUR_SERVER_ID 的地方都用它替换。

Gemini CLI 从 ~/.gemini/settings.json(Windows 上为 %USERPROFILE%\.gemini\settings.json)读取 MCP 服务器。添加:

{
  "mcpServers": {
    "anythingmcp": {
      "httpUrl": "https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID",
      "headers": { "X-API-Key": "YOUR_MCP_API_KEY" }
    }
  }
}
  1. 在 AnythingMCP 的 MCP Servers → 你的服务器 → API keys 中创建 MCP API 密钥,并用它替换 YOUR_MCP_API_KEY。
  2. 保存文件并重启 gemini。
  3. 在 Gemini CLI 中运行 /mcp(或在终端运行 gemini mcp list),anythingmcp 应显示为已连接。
  4. 开始输入提示,Gemini CLI 现在可以调用 GitLab 的工具。

可用工具

ToolWhat it does
gitlab_get_current_userGet the GitLab user the token belongs to: id, username, name, state, web_url and, for admins, is_admin
gitlab_list_projectsList projects the token can see, newest activity first by default: id, path_with_namespace, default_branch, web_url, visibility and…
gitlab_get_projectGet one project by id or path: default_branch, visibility, description, web_url, open_issues_count, permissions of the token's user, and…
gitlab_list_project_membersList the members of a project, including those inherited from its groups: user id, username, name and access_level (10 Guest, 15 Planner…
gitlab_list_labelsList a project's labels (including group labels): name, color, description and open issue and merge request counts
gitlab_list_issuesList a project's issues with filters: iid, title, state, labels, assignees, author, milestone, due_date, web_url
gitlab_list_my_issuesList issues across all projects: by default the ones assigned to the token's user, or the ones they created, or every issue they can see
gitlab_get_issueGet one issue by its iid: title, description (Markdown), state, labels, assignees, author, milestone, due_date, time stats, related merge…
gitlab_create_issueCreate an issue in a project
gitlab_update_issueChange an issue: title, description, labels (replace, add or remove), assignees, milestone, due date, or close or reopen it with state_event
gitlab_delete_issueDelete an issue for good
gitlab_list_issue_notesList the comments on an issue, newest first by default, including system notes (label and status changes, flagged system: true): id, body…
gitlab_add_issue_notePost a comment on an issue, as the token's user
gitlab_list_merge_requestsList a project's merge requests with filters: iid, title, state, draft, source and target branch, author, reviewers, labels, merge_status…
gitlab_list_my_merge_requestsList merge requests across all projects: by default the ones created by the token's user, or assigned to them, or waiting for their review…
gitlab_get_merge_requestGet one merge request by iid: title, description, state, draft, source and target branch, sha, detailed_merge_status (mergeable, conflict…
gitlab_get_merge_request_diffsGet the changed files of a merge request, page by page: old_path, new_path, new_file, renamed_file, deleted_file and the diff text of each
gitlab_list_merge_request_commitsList the commits of a merge request: id (SHA), short_id, title, message, author_name and created_at
gitlab_list_merge_request_notesList the comments on a merge request, including review comments on lines (with a position) and system notes: id, body, author, created_at…
gitlab_add_merge_request_notePost a general comment on a merge request, as the token's user
gitlab_create_merge_requestOpen a merge request from a source branch into a target branch
gitlab_update_merge_requestChange a merge request: title (add or remove the Draft: prefix), description, target branch, labels, assignees, reviewers, or close or…
gitlab_list_pipelinesList a project's CI/CD pipelines, newest first: id, iid, status, ref, sha, source, created_at, updated_at and web_url
gitlab_get_pipelineGet one pipeline: status, ref, sha, source, duration, queued_duration, coverage, user, started_at, finished_at and web_url
gitlab_list_pipeline_jobsList the jobs of a pipeline: id, name, stage, status, failure_reason, duration, runner, allow_failure and web_url
gitlab_get_jobGet one CI/CD job: name, stage, status, failure_reason, duration, started_at, finished_at, the commit, the pipeline, artifacts and web_url
gitlab_get_job_logRead the log (trace) of a CI/CD job as plain text, with ANSI color codes
gitlab_list_branchesList a project's branches: name, merged, protected, default, the last commit (id, title, author, date) and web_url
gitlab_get_branchGet one branch: its last commit, whether it is merged, protected or the default, and whether the user can push to it
gitlab_create_branchCreate a branch from a branch, tag or commit
gitlab_delete_branchDelete a branch
gitlab_list_commitsList commits of a branch, tag or the default branch, newest first: id (SHA), short_id, title, author_name, authored_date and web_url
gitlab_get_commitGet one commit by SHA, branch or tag name: message, author, committer, parent_ids, stats (additions, deletions), the last pipeline and…
gitlab_get_commit_diffGet the changes of one commit, page by page: old_path, new_path, new_file, renamed_file, deleted_file and the diff text per file
gitlab_list_repository_treeList files and folders in a repository folder: id (blob or tree SHA), name, type (blob = file, tree = folder), path and mode.…
gitlab_get_file_infoGet a file's metadata without its content: file_name, file_path, size, encoding, content_sha256, blob_id, commit_id and last_commit_id on…
gitlab_get_file_contentRead a file from the repository as text, at a branch, tag or commit (the default branch by default)
gitlab_searchSearch the whole instance (only what the token's user can see): projects, groups, issues, work_items, merge_requests, milestones, users or…
gitlab_search_projectSearch inside one project: code (blobs, with file name, path, line number and the matching lines), commits, issues, merge_requests…

示例提示

  • “所有项目中有哪些合并请求在等我审阅?其中哪些有冲突或流水线失败?”
  • “my-group/web-app 的 main 分支上最新一次流水线为什么失败?给我看失败的作业和日志里的错误。”
  • “总结 my-group/web-app 中的合并请求 !128:改了什么、涉及哪些文件,以及哪些审阅评论还没有解决。”
  • “在 my-group/web-app 中创建一个议题,标题为“移动端结账按钮错位”,加上 bug 标签,并指派给 Lena。”

FAQ

Gemini CLI 从哪里读取 MCP 服务器? 用户级配置位于 ~/.gemini/settings.json,项目级配置位于项目内的 .gemini/settings.json。gemini mcp list 会列出每个服务器及其连接状态。

下一步

这份指南对你有帮助吗?

你的 GitLab 智能体只差一次点击。

安装连接器,粘贴密钥,向 Gemini 提问。免费试用 7 天,无需信用卡。

相关指南

连接器

如何通过 MCP 将 GitLab 连接到 ChatGPT

让你的 AI 在 GitLab 中工作:查找项目,分拣和更新议题(issue),审阅合并请求(merge request)及其差异和评论,检查流水线并阅读失败作业的日志,以及读取分支、提交和文件。支持 GitLab.com 或你自己的 GitLab 实例,使用个人访问令牌。

连接器

如何通过 MCP 将 GitLab 连接到 Claude

让你的 AI 在 GitLab 中工作:查找项目,分拣和更新议题(issue),审阅合并请求(merge request)及其差异和评论,检查流水线并阅读失败作业的日志,以及读取分支、提交和文件。支持 GitLab.com 或你自己的 GitLab 实例,使用个人访问令牌。

连接器

如何通过 MCP 将 GitLab 连接到 Cursor

让你的 AI 在 GitLab 中工作:查找项目,分拣和更新议题(issue),审阅合并请求(merge request)及其差异和评论,检查流水线并阅读失败作业的日志,以及读取分支、提交和文件。支持 GitLab.com 或你自己的 GitLab 实例,使用个人访问令牌。

连接器

如何通过 MCP 将 GitLab 连接到 Meta Muse

让你的 AI 在 GitLab 中工作:查找项目,分拣和更新议题(issue),审阅合并请求(merge request)及其差异和评论,检查流水线并阅读失败作业的日志,以及读取分支、提交和文件。支持 GitLab.com 或你自己的 GitLab 实例,使用个人访问令牌。

连接器

GitLab 接入 MCP:从任意 AI 代理驱动 GitLab

让你的 AI 在 GitLab 中工作:查找项目,分拣和更新议题(issue),审阅合并请求(merge request)及其差异和评论,检查流水线并阅读失败作业的日志,以及读取分支、提交和文件。支持 GitLab.com 或你自己的 GitLab 实例,使用个人访问令牌。

连接器

如何通过 MCP 将 Canva 连接到 Gemini

让你的 AI 在 Canva 中工作:查找和读取设计,创建新设计,将设计导出为 PDF、PNG、PowerPoint 或视频并获取下载链接,整理文件夹,通过链接上传图片,读取品牌模板,并在设计上发表评论。