使用说明
GitLab MCP服务器
该仓库为GitLab服务器提供模型上下文协议服务器。
API版本
- v18.1
构建
构建二进制文件。
go build -o bin/gitlab-mcp-server ./cmd/gitlab-mcp-server/main.go
或者构建容器映像。
docker build -t gitlab-mcp-server .
添加 Z 中绑定装载操作时的选项 Dockerfile 如果将podman与SELinux结合使用。
用法
运行应用程序。
指定令牌。
$ ./bin/gitlab-mcp-server -h
GitLab MCP Server
Usage:
gitlab-mcp-server [flags]
Flags:
-h, --help help for gitlab-mcp-server
--readonly HTTP GET method only. (default true)
--token string GitLab server token.
--url string GitLab server URL. (default "https://127.0.0.1")
-v, --version version for gitlab-mcp-server
设置环境变量而不是参数。
| 参数 | 环境变量 |
|---|---|
| --URL | gitlab URL |
| --令牌 | gitlab令牌 |
| --只读 | GITLAB_readonly |
或者运行容器。
docker run --rm -i -e GITLAB_URL=<URL> -e GITLAB_TOKEN=<TOKEN> gitlab-mcp-server
使用VS代码
添加 gitlab-mcp-server 二进制到 PATH 环境变量和配置VS代码。
{
"servers": {
"gitlab": {
"type": "stdio",
"command": "gitlab-mcp-server",
"env": {
"GITLAB_URL": "${input:gitlab_url}",
"GITLAB_TOKEN": "${input:gitlab_token}",
}
}
},
"inputs": [
{
"type": "promptString",
"id": "gitlab_url",
"description": "GitLab Server URL",
"password": false
},
{
"type": "promptString",
"id": "gitlab_token",
"description": "GitLab Server TOKEN",
"password": true
}
]
}
工具
待办事项
测试
检查此MCP服务器是否正确使用 mcpcurl.
列出此MCP服务器中的工具。
mcpcurl tools --pretty=false --stdio-server-cmd ./bin/gitlab-mcp-server
显示工具的帮助。
mcpcurl tools --pretty=false --stdio-server-cmd ./bin/gitlab-mcp-server <tool> --help
例如,获取版本。
mcpcurl tools \
--pretty=false \
--stdio-server-cmd "./bin/gitlab-mcp-server --url=<URL> --token=<TOKEN>" \
get_version
例如,获得项目。
mcpcurl tools \
--pretty=false \
--stdio-server-cmd "./bin/gitlab-mcp-server --url=<URL> --token=<TOKEN>" \
get_pjs
检查架构。
mcpcurl schema --pretty=false --stdio-server-cmd ./bin/gitlab-mcp-server
检查此MCP服务器是否正确使用 @模型上下文协议/检查器.
npx @modelcontextprotocol/inspector ./bin/gitlab-mcp-server --url=<URL> --token=<TOKEN>
备注
- 在GitHub Copilot Chat面板的[工具图标]处检查未使用的工具,因为vscode限制了最多128个工具。
