如何将 GitLab 远程 MCP 连接到 VS Code
约 1 分钟即可把 GitLab 的远程 MCP 服务端接入 VS Code。如需排查 OAuth / 401 问题,可先用 OAuth 2.1 调试器体检端点。
Streamable HTTPhttps://gitlab.com/api/v4/mcp
Install in Cursor →
Or add to ~/.cursor/mcp.json:
{
"mcpServers": {
"gitlab": {
"url": "https://gitlab.com/api/v4/mcp"
}
}
}claude mcp add --transport http gitlab https://gitlab.com/api/v4/mcp
Install in VS Code →
Or add to .vscode/mcp.json:
{
"servers": {
"gitlab": {
"type": "http",
"url": "https://gitlab.com/api/v4/mcp"
}
}
}- Open Settings → Connectors (Integrations) → Add Custom Connector.
- Paste the endpoint URL:
https://gitlab.com/api/v4/mcp - Complete the browser OAuth 2.1 login flow when prompted.
Bridge the remote endpoint into stdio with mcp-remote in claude_desktop_config.json:
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://gitlab.com/api/v4/mcp"
]
}
}
}Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"gitlab": {
"serverUrl": "https://gitlab.com/api/v4/mcp"
}
}
}Add to ~/.kiro/settings/mcp.json (or .kiro/settings/mcp.json in your workspace), then reopen Kiro's Agent panel to pick up the server:
{
"mcpServers": {
"gitlab": {
"url": "https://gitlab.com/api/v4/mcp"
}
}
}Add to ~/.codex/config.toml — Codex reads remote HTTP servers from [mcp_servers.*] tables:
[mcp_servers.gitlab] url = "https://gitlab.com/api/v4/mcp"
Add to cline_mcp_settings.json (Cline → MCP Servers → Configure), or paste it via Cline's MCP marketplace file:
{
"mcpServers": {
"gitlab": {
"type": "streamableHttp",
"url": "https://gitlab.com/api/v4/mcp"
}
}
}Add to ~/.gemini/settings.json under mcpServers — httpUrl for Streamable HTTP, url for legacy SSE:
{
"mcpServers": {
"gitlab": {
"httpUrl": "https://gitlab.com/api/v4/mcp"
}
}
}接入步骤
- 打开 MCP 配置 — 使用本页 vscode: deeplink 一键安装,或在项目根目录创建
.vscode/mcp.json。 - 添加服务端 — 写入
{ "servers": { "gitlab": { "type": "http", "url":https://gitlab.com/api/v4/mcp} } }。 - 完成认证 — 首次调用时客户端会打开 GitLab 的 OAuth 授权页面——点击允许后工具即可用。
- 验证 — 重启 Copilot Chat 选择 Agent 模式后可看到工具。在 在线 Inspector 中粘贴
https://gitlab.com/api/v4/mcp并运行 initialize + tools/list 验证连通性。
🧰 工具预览(22)
| Tool | Safety | Description | Parameters |
|---|---|---|---|
| mcp_search ~34 tok | 🟢 Read | Search GitLab projects, issues and merge requests. | — |
| get_project ~30 tok | 🟢 Read | Get details of a GitLab project. | — |
| list_projects ~28 tok | 🟢 Read | List GitLab projects. | — |
| get_file_contents ~31 tok | 🟢 Read | Read a file from a repository. | — |
| get_issue ~26 tok | 🟢 Read | Get a GitLab issue. | — |
| list_issues ~28 tok | 🟢 Read | List issues of a project. | — |
| create_issue ~28 tok | 🟠 Write | Create a GitLab issue. | — |
| create_issue_note ~29 tok | 🟠 Write | Add a note to an issue. | — |
| get_merge_request ~29 tok | 🟢 Read | Get a merge request. | — |
| list_merge_requests ~32 tok | 🟢 Read | List merge requests of a project. | — |
| create_merge_request ~30 tok | 🟠 Write | Create a merge request. | — |
| create_merge_request_note ~33 tok | 🟠 Write | Add a note to a merge request. | — |
| get_pipeline ~28 tok | 🟢 Read | Get a CI/CD pipeline. | — |
| list_pipelines ~30 tok | 🟢 Read | List pipelines of a project. | — |
| get_job ~26 tok | 🟢 Read | Get a pipeline job. | — |
| get_milestone ~29 tok | 🟢 Read | Get a project milestone. | — |
| list_milestones ~29 tok | 🟢 Read | List project milestones. | — |
| get_commit ~25 tok | 🟢 Read | Get a commit. | — |
| list_branches ~29 tok | 🟢 Read | List repository branches. | — |
| create_branch ~29 tok | 🟠 Write | Create a repository branch. | — |
| list_tags ~27 tok | 🟢 Read | List repository tags. | — |
| run_pipeline ~29 tok | 🟠 Write | Trigger a CI/CD pipeline. | — |