● 免费开源💻 本地🔑 需要 API 密钥编程
GitLab MCP Server
让你的智能体处理 GitLab 项目、合并请求、议题、流水线、wiki 和发布版本。
2.1k GitHub 星标作者 zereight许可证 MIT更新于 18天前
如何安装
这个 MCP 是本地的:在你的电脑上运行。
适用于电脑上安装的应用(Claude Desktop、Claude Code、Cursor、VS Code 等)。选择你的应用:
粘贴到终端:
claude mcp add gitlab -- npx -y @zereight/mcp-gitlab
需要填写的内容
| 名称 | 用途 | 必填 |
|---|---|---|
GITLAB_PERSONAL_ACCESS_TOKEN | GitLab personal access token for local stdio use. A non-empty value overrides GITLAB_PERSONAL_ACCESS_TOKEN_FILE. One of this token, GITLAB_PERSONAL_ACCESS_TOKEN_FILE, GITLAB_JOB_TOKEN, GITLAB_AUTH_COOKIE_PATH, or GITLAB_USE_OAUTH=true must be set. Create a token with the GitLab scopes the tools need, such as api or read_api. | 否 |
GITLAB_PERSONAL_ACCESS_TOKEN_FILE | Path to a file that contains the personal access token. Read once at startup and trimmed. Ignored when GITLAB_PERSONAL_ACCESS_TOKEN or --token is non-empty. A missing, unreadable, or empty file stops startup. Does not replace job token, OAuth, cookie, or remote authorization. | 否 |
GITLAB_JOB_TOKEN | Optional GitLab CI job token to use instead of a personal access token when running inside GitLab CI. | 否 |
GITLAB_AUTH_COOKIE_PATH | Optional path to a GitLab authentication cookie file for cookie-based authentication. | 否 |
GITLAB_USE_OAUTH | Set to true to start with GitLab OAuth instead of a personal access token, job token, or cookie file. | 否 |
GITLAB_OAUTH_CLIENT_ID | GitLab OAuth application ID. When GITLAB_USE_OAUTH=true, set this or GITLAB_OAUTH_TOKEN_SCRIPT. | 否 |
GITLAB_OAUTH_TOKEN_SCRIPT | Command that prints an OAuth access token. When GITLAB_USE_OAUTH=true, set this or GITLAB_OAUTH_CLIENT_ID. | 否 |
GITLAB_API_URL | GitLab API base URL. Use https://gitlab.com/api/v4 for GitLab.com or your self-managed GitLab API URL. | 否 |
GITLAB_ALLOWED_PROJECT_IDS | Optional comma-separated list of GitLab project IDs that this server is allowed to access. | 否 |
GITLAB_PERMISSION_MODE | Tool exposure. Allowed values are readonly, modify, and full. Unset uses full. readonly keeps read-only tools. modify blocks delete and teardown tools. | 否 |
GITLAB_TOOLSETS | Optional comma-separated toolset ids (projects, issues, merge_requests, …). Unset keeps the lean core default plus discover_tools. Do not set all unless you accept loading ~all schemas (~73k tokens). | 否 |
GITLAB_TOOLS | Optional comma-separated list of individual tool names to add on top of enabled toolsets. | 否 |
GITLAB_DENIED_TOOLS_REGEX | Optional regular expression used to hide matching tools from the server. | 否 |
GITLAB_TOOL_POLICY_APPROVE | Optional comma-separated list of tool names that require explicit approval before execution. | 否 |
GITLAB_TOOL_POLICY_HIDDEN | Optional comma-separated list of tool names to hide from tools/list. | 否 |
NODE_TLS_REJECT_UNAUTHORIZED | Set to 0 only when you intentionally need to connect to a GitLab instance with invalid or self-signed TLS certificates. | 否 |
GITLAB_CA_CERT_PATH | Optional path to a custom CA certificate file for self-managed GitLab instances. | 否 |
GITLAB_MASKING_ENABLED | Set to true to mask text tool results and returned errors using built-in or configured rules. | 否 |
GITLAB_MASKING_CONFIG | Optional path to a response-masking JSON configuration file. | 否 |
GITLAB_MASKING_POLICY_FILE | Optional protected server-owned JSON file containing managed masking policies. | 否 |
GITLAB_MASKING_WORKSPACE_DIR | Directory used to resolve response-masking configuration paths. | 否 |
好了!现在试试
重启应用,把下面任意一条请求粘贴到聊天里:
帮我列出 group/project 中合并请求 123 的变更文件。
把失败的流水线任务的输出给我看看。
简介
这个服务器通过 REST 和 GraphQL API 把你的智能体连接到 GitLab。它开始时提供 40 个工具,并可以按类别启用更多工具,最多共 288 个。支持 gitlab.com 和自托管实例,也支持只读模式。
它能做什么
list_merge_request_changed_files和get_merge_request_file_diff:分两步审查合并请求get_pipeline_job_output:分页读取任务日志discover_tools:启用更多工具类别helpexecute_graphql- 项目、议题、wiki、发布版本、标签和里程碑
jmespath选项,用于缩小大型结果
什么时候用
- ›当你希望智能体逐个文件审查合并请求时。
- ›当流水线失败,而你想在不打开 GitLab 的情况下查看任务日志时。
- ›当你想在聊天中管理议题和里程碑时。
你需要准备
一个 GitLab 个人访问令牌(或 OAuth),以及 Node.js 20 或更高版本。用
npm install -g @zereight/mcp-gitlab 安装,然后使用 zereight-mcp-gitlab 可执行文件。搭配的技能
MCP 还是技能?
MCP 给智能体“双手”,技能教它正确的用法。两者结合,结果更好,也更省 token。
常见问题
默认会显示多少个工具?
默认 40 个(38 个核心工具,加上 discover_tools 和 help)。总共有 288 个。
我应该加载所有工具吗?
不应该。读我文件建议不要设置 GITLAB_TOOLSETS=all,那会多占用约 73k 个结构 token。请改用 discover_tools。
如何登录?
可以使用 GITLAB_PERSONAL_ACCESS_TOKEN、本地 OAuth、用于 Claude.ai 的 MCP OAuth,或按请求的远程授权。
能用于自托管 GitLab 吗?
可以,把 GITLAB_API_URL 设为你的实例地址。
不用 MCP 也能用吗?
可以。Skill 和 CLI 方式可以在终端里用 zereight-mcp-gitlab 完成同样的工作流程。
api 工具集安全吗?
读我文件警告说,它会绕过允许列表和安全检查,并可能被提示注入控制。只在你明确需要时才启用。
如果不能用
- ›检查令牌是否已设置,以及 GITLAB_API_URL 是否正确,例如 https://gitlab.com/api/v4。
- ›检查你的 Node.js 版本是否为 20 或更高。
- ›对于 project_id,请使用经过 URL 编码的项目路径,例如 group%2Fproject。
每周 5 个新技能,1 分钟读完。