GitLab MCP 是 AI Skill Hub 本期精选MCP工具之一。已获得 1.6k 颗 GitHub Star,综合评分 7.5 分,整体质量较高。我们推荐使用将其纳入你的 AI 工具库,帮助提升工作效率。
GitLab MCP 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
GitLab MCP 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/zereight/gitlab-mcp
# 方式二:手动配置 claude_desktop_config.json
{
"mcpServers": {
"gitlab-mcp": {
"command": "npx",
"args": ["-y", "gitlab-mcp"]
}
}
}
# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
# 安装后在 Claude 对话中直接使用 # 示例: 用户: 请帮我用 GitLab MCP 执行以下任务... Claude: [自动调用 GitLab MCP MCP 工具处理请求] # 查看可用工具列表 # 在 Claude 中输入:"列出所有可用的 MCP 工具"
// claude_desktop_config.json 配置示例
{
"mcpServers": {
"gitlab_mcp": {
"command": "npx",
"args": ["-y", "gitlab-mcp"],
"env": {
// "API_KEY": "your-api-key-here"
}
}
}
}
// 保存后重启 Claude Desktop 生效
New Feature: Dynamic GitLab API URL support with connection pooling! See Dynamic API URL Documentation for details.
The server supports four authentication methods:
For local/desktop use (most common):
GITLAB_PERSONAL_ACCESS_TOKEN) — simplest setupGITLAB_USE_OAUTH) — recommended for better securityFor server/remote deployments:
GITLAB_MCP_OAUTH) — for remote MCP clients such as Claude.aiREMOTE_AUTHORIZATION) — multi-user deployments where each caller provides their own tokenFor the simplest local setup, start with a Personal Access Token. For browser-based local auth, use OAuth2. For remote or multi-user deployments, continue to the MCP OAuth and Remote Authorization sections later in this README.
Some MCP clients (like GitHub Copilot CLI) have issues with environment variables. Use CLI arguments instead:
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"@zereight/mcp-gitlab",
"--token=YOUR_GITLAB_TOKEN",
"--api-url=https://gitlab.com/api/v4"
],
"tools": ["*"]
}
}
}
Available CLI arguments:
--token - GitLab Personal Access Token (replaces GITLAB_PERSONAL_ACCESS_TOKEN)--api-url - GitLab API URL (replaces GITLAB_API_URL)--read-only=true - Enable read-only mode (replaces GITLAB_READ_ONLY_MODE)--use-wiki=true - Enable wiki API (replaces USE_GITLAB_WIKI)--use-milestone=true - Enable milestone API (replaces USE_MILESTONE)--use-pipeline=true - Enable pipeline API (replaces USE_PIPELINE)CLI arguments take precedence over environment variables.
docker run -i --rm \
-e HOST=0.0.0.0 \
-e GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token \
-e GITLAB_API_URL="https://gitlab.com/api/v4" \
-e GITLAB_READ_ONLY_MODE=true \
-e USE_GITLAB_WIKI=true \
-e USE_MILESTONE=true \
-e USE_PIPELINE=true \
-e SSE=true \
-p 3333:3002 \
zereight050/gitlab-mcp
{
"mcpServers": {
"gitlab": {
"type": "sse",
"url": "http://localhost:3333/sse"
}
}
}
docker run -i --rm \
-e HOST=0.0.0.0 \
-e REMOTE_AUTHORIZATION=true \
-e GITLAB_API_URL="https://gitlab.com/api/v4" \
-e GITLAB_READ_ONLY_MODE=true \
-e USE_GITLAB_WIKI=true \
-e USE_MILESTONE=true \
-e USE_PIPELINE=true \
-e STREAMABLE_HTTP=true \
-p 3333:3002 \
zereight050/gitlab-mcp
{
"mcpServers": {
"gitlab": {
"type": "streamable-http",
"url": "http://localhost:3333/mcp",
"headers": {
"Authorization": "Bearer glpat-..."
}
}
}
}
GITLAB_MCP_OAUTH)For server/remote deployments only. This mode requires the MCP server to be deployed with a publicly accessible HTTPS URL. For local/desktop use, see GITLAB_USE_OAUTH above.
For remote MCP clients that support the MCP OAuth specification (e.g. Claude.ai). The server acts as a full OAuth 2.0 authorization server — unauthenticated requests receive a 401 + WWW-Authenticate response, which triggers the OAuth browser flow automatically on the client side.
Remote MCP clients such as OpenCode, MCPJam, and Claude.ai can send their own callback URL during authorization. If you cannot register every client callback URL in GitLab, enable GITLAB_OAUTH_CALLBACK_PROXY=true. With callback proxy mode, GitLab only needs one registered redirect URI: {MCP_SERVER_URL}/callback.
GITLAB_OAUTH_REDIRECT_URI is for local OAuth (GITLAB_USE_OAUTH) only. It does not override remote MCP OAuth client callback URLs and should not be used to fix remote Unregistered redirect_uri errors.
This variable exists because the local OAuth flow starts a browser on the same machine as the MCP server and listens for the callback on a local HTTP server, for example http://127.0.0.1:8888/callback.
Remote MCP OAuth is different. In GITLAB_MCP_OAUTH=true mode, the MCP client provides its own callback URL during /authorize. GITLAB_OAUTH_REDIRECT_URI does not replace that client-provided URL.
| Mode | Enable with | Callback variable | GitLab redirect URI |
|---|---|---|---|
| Local OAuth | GITLAB_USE_OAUTH=true | GITLAB_OAUTH_REDIRECT_URI | http://127.0.0.1:8888/callback or your local callback |
| Remote MCP OAuth | GITLAB_MCP_OAUTH=true | GITLAB_OAUTH_CALLBACK_PROXY=true | {MCP_SERVER_URL}/callback |
Use GITLAB_OAUTH_REDIRECT_URI only when the MCP server itself owns the local browser callback. Use GITLAB_OAUTH_CALLBACK_PROXY=true when a remote MCP client owns the callback URL.
How it works: You deploy this MCP server somewhere with a public HTTPS URL. MCP clients connect to {MCP_SERVER_URL}/mcp. The server handles the OAuth 2.0 flow, exchanging credentials with GitLab on behalf of the client.
Prerequisites:
1. A publicly accessible HTTPS server URL (MCP_SERVER_URL) — use ngrok for local testing 2. A pre-registered GitLab OAuth application with api (or read_api) scopes — Go to Admin area → Applications, set Redirect URI to {MCP_SERVER_URL}/callback
| Environment Variable | Required | Description |
|---|---|---|
GITLAB_MCP_OAUTH | ✅ | Set to true to enable |
GITLAB_API_URL | ✅ | GitLab API base URL |
GITLAB_OAUTH_APP_ID | ✅ | GitLab OAuth Application ID |
MCP_SERVER_URL | ✅ | Public HTTPS URL of this MCP server |
STREAMABLE_HTTP | ✅ | Must be true |
GITLAB_OAUTH_CALLBACK_PROXY | optional | Set to true to use the MCP server's fixed /callback URL |
GITLAB_OAUTH_SCOPES | optional | Comma-separated scopes (default: api,read_api,read_user) |
When STREAMABLE_HTTP=true, server-side GITLAB_PERSONAL_ACCESS_TOKEN or GITLAB_JOB_TOKEN require REMOTE_AUTHORIZATION=true or GITLAB_MCP_OAUTH=true.
TroubleshootingUnregistered redirect_uriCheck theredirect_uriin the browser URL. If it points to a client callback such ashttp://127.0.0.1:xxxxx/.../callback, enable:Do not fix remote MCP OAuth by changing> GITLAB_OAUTH_CALLBACK_PROXY=true >GITLAB_OAUTH_REDIRECT_URI. That variable is for local OAuth (GITLAB_USE_OAUTH) only.
docker run -i --rm \
-e HOST=0.0.0.0 \
-e GITLAB_MCP_OAUTH=true \
-e GITLAB_OAUTH_CALLBACK_PROXY=true \
-e STREAMABLE_HTTP=true \
-e MCP_SERVER_URL=https://your-server.example.com \
-e GITLAB_API_URL="https://gitlab.com/api/v4" \
-e GITLAB_OAUTH_APP_ID=your_app_id \
-p 3000:3002 \
zereight050/gitlab-mcp
MCP client configuration:
{
"mcpServers": {
"gitlab": {
"type": "http",
"url": "https://your-server.example.com/mcp"
}
}
}
REMOTE_AUTHORIZATION)For server/remote deployments only. Each HTTP caller provides their own GitLab token directly in request headers — no OAuth flow involved.
For multi-user or multi-tenant deployments where each caller provides their own GitLab token in the HTTP request header. No OAuth flow — the MCP server forwards the token to GitLab on behalf of the caller.
Header priority: Private-Token > JOB-TOKEN > Authorization: Bearer
| Environment Variable | Required | Description |
|---|---|---|
REMOTE_AUTHORIZATION | ✅ | Set to true to enable |
STREAMABLE_HTTP | ✅ | Must be true |
ENABLE_DYNAMIC_API_URL | optional | Allow per-request GitLab URL via X-GitLab-API-URL header |
Example request headers:
Private-Token: glpat-xxxxxxxxxxxxxxxxxxxx
or using a Bearer token:
Authorization: Bearer glpat-xxxxxxxxxxxxxxxxxxxx
⚠️REMOTE_AUTHORIZATIONis not compatible with SSE transport.STREAMABLE_HTTP=trueis required.
When using REMOTE_AUTHORIZATION=true, the MCP server can support multiple users, each with their own GitLab token passed via HTTP headers. This is useful for:
Setup Example:
```bash
When using GITLAB_MCP_OAUTH=true, the server acts as an OAuth proxy to your GitLab instance. Claude.ai (and any MCP-spec-compliant client) handles the entire browser authentication flow automatically — no manual Personal Access Token management needed.
Prerequisites:
A pre-registered GitLab OAuth application is required. GitLab restricts dynamically registered (unverified) applications to the mcp scope, which is insufficient for API calls (need api or read_api).
1. Go to your GitLab instance → Admin Area > Applications (instance-wide) or User Settings > Applications (personal) 2. Create a new application with: - Confidential: unchecked - Scopes: api, read_api, read_user (or whichever scopes you intend to request via GITLAB_OAUTH_SCOPES) 3. Save and copy the Application ID — this is your GITLAB_OAUTH_APP_ID
How it works:
/.well-known/oauth-authorization-serverPOST /register) — handled locally by the MCP server (each client gets a virtual client ID)https://claude.ai/api/mcp/auth_callbackAuthorization: Bearer <token> on every MCP requestServer setup:
docker run -d \
-e STREAMABLE_HTTP=true \
-e GITLAB_MCP_OAUTH=true \
-e GITLAB_OAUTH_APP_ID="your-gitlab-oauth-app-client-id" \
-e GITLAB_API_URL="https://gitlab.example.com/api/v4" \
-e MCP_SERVER_URL="https://your-mcp-server.example.com" \
-p 3002:3002 \
zereight050/gitlab-mcp
For local development (HTTP allowed):
MCP_DANGEROUSLY_ALLOW_INSECURE_ISSUER_URL=true \
STREAMABLE_HTTP=true \
GITLAB_MCP_OAUTH=true \
GITLAB_OAUTH_APP_ID=your-gitlab-oauth-app-client-id \
MCP_SERVER_URL=http://localhost:3002 \
GITLAB_API_URL=https://gitlab.com/api/v4 \
node build/index.js
Claude.ai configuration:
{
"mcpServers": {
"GitLab": {
"url": "https://your-mcp-server.example.com/mcp"
}
}
}
No headers field is needed — Claude.ai obtains the token via OAuth automatically.
Environment variables:
| Variable | Required | Description |
|---|---|---|
GITLAB_MCP_OAUTH | Yes | Set to true to enable |
GITLAB_OAUTH_APP_ID | Yes | Client ID of the pre-registered GitLab OAuth application |
MCP_SERVER_URL | Yes | Public HTTPS URL of your MCP server |
GITLAB_API_URL | Yes | Your GitLab instance API URL (e.g. https://gitlab.com/api/v4) |
STREAMABLE_HTTP | Yes | Must be true (SSE is not supported) |
GITLAB_OAUTH_SCOPES | No | Comma-separated GitLab scopes to request (e.g. api,read_user). Defaults to api (or read_api when GITLAB_READ_ONLY_MODE=true). The pre-registered application must be configured with at least these scopes. |
MCP_DANGEROUSLY_ALLOW_INSECURE_ISSUER_URL | No | Set true for local HTTP dev only |
Important Notes:
- MCP OAuth only works with Streamable HTTP transport (SSE=true is incompatible) - Each user session stores its own OAuth token — sessions are fully isolated - Session timeout, rate limiting, and capacity limits apply identically to the REMOTE_AUTHORIZATION mode (SESSION_TIMEOUT_SECONDS, MAX_REQUESTS_PER_MINUTE, MAX_SESSIONS) - Header auth fallback: when Private-Token or JOB-TOKEN request headers are present, OAuth validation is skipped and the raw token is used directly for that session. This allows PATs and CI job tokens to be used alongside the OAuth flow on the same server instance. Authorization: Bearer is always treated as an OAuth token — use Private-Token for PAT-based header auth.
Use the dedicated reference for the full environment variable list:
Most users only need one of these starting sets:
GITLAB_PERSONAL_ACCESS_TOKEN, GITLAB_API_URLGITLAB_USE_OAUTH=true, GITLAB_OAUTH_CLIENT_ID, GITLAB_OAUTH_REDIRECT_URI, GITLAB_API_URLSTREAMABLE_HTTP=true, REMOTE_AUTHORIZATION=true, HOST, PORTOAUTH_STATELESS_MODE=true, OAUTH_STATELESS_SECRET (same across all pods). See Stateless Mode.Commonly referenced variables:
GITLAB_API_URLGITLAB_PERSONAL_ACCESS_TOKENGITLAB_USE_OAUTHREMOTE_AUTHORIZATIONGITLAB_MCP_OAUTHGITLAB_OAUTH_CALLBACK_PROXYOAUTH_STATELESS_MODEOAUTH_STATELESS_SECRETThe reference document also covers:
discover_tools (on-demand toolset activation)For callback proxy mode details, see GitLab MCP OAuth Callback Proxy.
npm test
npm run test:integration ```
All remote authorization tests use a mock GitLab server and do not require actual GitLab credentials.
GitLab MCP是一个开源的MCP工具,提供了一个简洁的API,易于使用和扩展,值得关注。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,GitLab MCP 在MCP工具赛道中表现稳健,质量良好。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | gitlab-mcp |
| Topics | mcptypescript |
| GitHub | https://github.com/zereight/gitlab-mcp |
| License | MIT |
| 语言 | TypeScript |
收录时间:2026-05-30 · 更新时间:2026-05-30 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端