这是一个为 GitLab API 提供支持的 MCP 服务器,支持项目管理、文件操作等多种功能。
create_or_update_file
project_id
(字符串):项目ID或URL编码路径file_path
(字符串):创建/更新文件的路径content
(字符串):文件内容commit_message
(字符串):提交信息branch
(字符串):创建/更新文件的分支previous_path
(可选字符串):要移动/重命名文件的原始路径push_files
project_id
(字符串):项目ID或URL编码路径branch
(字符串):推送目标分支files
(数组):要推送的文件数组,每个包含file_path
和content
commit_message
(字符串):提交信息search_repositories
search
(字符串):搜索查询page
(可选数字):分页页码per_page
(可选数字):每页结果数(默认20)create_repository
name
(字符串):项目名称description
(可选字符串):项目描述visibility
(可选字符串):'private'(私有)、'internal'(内部)或'public'(公开)initialize_with_readme
(可选布尔值):是否使用README初始化get_file_contents
project_id
(字符串):项目ID或URL编码路径file_path
(字符串):文件/目录路径ref
(可选字符串):获取内容的分支/标签/提交create_issue
project_id
(字符串):项目ID或URL编码路径title
(字符串):问题标题description
(可选字符串):问题描述assignee_ids
(可选数字数组):分配的用户IDlabels
(可选字符串数组):要添加的标签milestone_id
(可选数字):里程碑IDcreate_merge_request
project_id
(字符串):项目ID或URL编码路径title
(字符串):MR标题description
(可选字符串):MR描述source_branch
(字符串):包含更改的分支target_branch
(字符串):合并目标分支draft
(可选布尔值):是否创建为草稿MRallow_collaboration
(可选布尔值):是否允许上游成员提交fork_repository
project_id
(字符串):项目ID或URL编码路径namespace
(可选字符串):分叉目标命名空间create_branch
project_id
(字符串):项目ID或URL编码路径branch
(字符串):新分支名称ref
(可选字符串):新分支的源分支/提交创建 GitLab 个人访问令牌,需要以下权限:
api
:完整API访问权限read_api
:只读访问权限read_repository
和 write_repository
:仓库操作权限将以下内容添加到你的 claude_desktop_config.json
文件中:
{
"mcpServers": {
"gitlab": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"GITLAB_PERSONAL_ACCESS_TOKEN",
"-e",
"GITLAB_API_URL",
"mcp/gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "<你的令牌>",
"GITLAB_API_URL": "https://gitlab.com/api/v4" // 可选,自托管实例使用
}
}
}
}

{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "<你的令牌>",
"GITLAB_API_URL": "https://gitlab.com/api/v4" // 可选,自托管实例使用
}
}
}
}

快速安装,请使用以下一键安装按钮之一...
对于手动安装,请将以下 JSON 块添加到 VS Code 的用户设置(JSON)文件中。可以通过按 Ctrl + Shift + P
并输入 Preferences: Open User Settings (JSON)
来完成。
可选地,你可以将它添加到工作区中的 .vscode/mcp.json
文件中。这将允许你与他人共享配置。
注意:在
.vscode/mcp.json
文件中不需要mcp
键。
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "gitlab_token",
"description": "GitLab Personal Access Token",
"password": true
},
{
"type": "promptString",
"id": "gitlab_url",
"description": "GitLab API URL (optional)",
"default": "https://gitlab.com/api/v4"
}
],
"servers": {
"gitlab": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"mcp/gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "${input:gitlab_token}",
"GITLAB_API_URL": "${input:gitlab_url}"
}
}
}
}
}

{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "gitlab_token",
"description": "GitLab Personal Access Token",
"password": true
},
{
"type": "promptString",
"id": "gitlab_url",
"description": "GitLab API URL (optional)",
"default": "https://gitlab.com/api/v4"
}
],
"servers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "${input:gitlab_token}",
"GITLAB_API_URL": "${input:gitlab_url}"
}
}
}
}
}

快速安装,请使用以下一键安装按钮...
要手动安装,请将以下 JSON 代码块添加到 VS Code 的用户设置 (JSON) 文件中。您可以按 Ctrl + Shift + P
并输入 Preferences: Open User Settings (JSON)
来完成此操作。
或者,您可以将其添加到工作区中的 .vscode/mcp.json
文件中。这允许您与他人共享配置。
请注意,
.vscode/mcp.json
文件中不需要mcp
密钥。
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "gitlab_token",
"description": "GitLab 个人访问令牌",
"password": true
},
{
"type": "promptString",
"id": "gitlab_url",
"description": "GitLab API URL (可选)",
"default": "https://gitlab.com/api/v4"
}
],
"servers": {
"gitlab": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"mcp/gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "${input:gitlab_token}",
"GITLAB_API_URL": "${input:gitlab_url}"
}
}
}
}
}

{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "gitlab_token",
"description": "GitLab 个人访问令牌",
"password": true
},
{
"type": "promptString",
"id": "gitlab_url",
"description": "GitLab API URL (可选)",
"default": "https://gitlab.com/api/v4"
}
],
"servers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "${input:gitlab_token}",
"GITLAB_API_URL": "${input:gitlab_url}"
}
}
}
}
}

Docker构建:
docker build -t vonwig/gitlab:mcp -f src/gitlab/Dockerfile .
GITLAB_PERSONAL_ACCESS_TOKEN
: 你的GitLab个人访问令牌(必填)GITLAB_API_URL
: GitLab API 的基础URL(可选,默认为 https://gitlab.com/api/v4
)本MCP服务器采用MIT许可证授权。这意味着您可以自由使用、修改和分发此软件,但须遵守MIT许可证的条款和条件。更多详情,请参阅项目仓库中的LICENSE文件。