GitLab MCP
识别到的语言类型为:英语 翻译结果:GitLab MCP
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"GitLab communication server": {
"args": [
"-y",
"@zereight/mcp-gitlab"
],
"command": "npx",
"env": {
"GITLAB_API_URL": "your_gitlab_api_url",
"GITLAB_PERSONAL_ACCESS_TOKEN": "your_gitlab_token",
"GITLAB_READ_ONLY_MODE": "true"
}
}
}
}
该服务需要配置环境变量:GITLAB_API_URL、GITLAB_PERSONAL_ACCESS_TOKEN
可用工具 (13 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
create_or_update_file 6 个参数 需填 5 项
Create or update a single file in a GitLab project
必填参数:project_id、file_path、content、commit_message、branch
search_repositories 3 个参数 需填 1 项
Search for GitLab projects
必填参数:search
create_repository 4 个参数 需填 1 项
Create a new GitLab project
必填参数:name
get_file_contents 3 个参数 需填 2 项
Get the contents of a file or directory from a GitLab project
必填参数:project_id、file_path
push_files 4 个参数 需填 4 项
Push multiple files to a GitLab project in a single commit
必填参数:project_id、branch、files、commit_message
create_issue 6 个参数 需填 2 项
Create a new issue in a GitLab project
必填参数:project_id、title
create_merge_request 7 个参数 需填 4 项
Create a new merge request in a GitLab project
必填参数:project_id、title、source_branch、target_branch
fork_repository 2 个参数 需填 1 项
Fork a GitLab project to your account or specified namespace
必填参数:project_id
create_branch 3 个参数 需填 2 项
Create a new branch in a GitLab project
必填参数:project_id、branch
get_merge_request 2 个参数 需填 2 项
Get details of a merge request
必填参数:project_id、merge_request_iid
get_merge_request_diffs 3 个参数 需填 2 项
Get the changes/diffs of a merge request
必填参数:project_id、merge_request_iid
update_merge_request 11 个参数 需填 2 项
Update a merge request
必填参数:project_id、merge_request_iid
create_note 4 个参数 需填 4 项
Create a new note (comment) to an issue or merge request
必填参数:project_id、noteable_type、noteable_iid、body
服务介绍
更好的 GitLab MCP 服务器
@zereight/mcp-gitlab
GitLab MCP(模型上下文协议)服务器。包含对原始 GitLab MCP 服务器的错误修复和改进。
使用方法
与 Claude App、Cline、Roo Code、Cursor 配合使用
在与 Claude App 配合使用时,您需要直接设置您的 API 密钥和 URL。
{
"mcpServers": {
"GitLab communication server": {
"command": "npx",
"args": ["-y", "@zereight/mcp-gitlab"],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "your_gitlab_token",
"GITLAB_API_URL": "your_gitlab_api_url",
"GITLAB_READ_ONLY_MODE": "true"
}
}
}
}
环境变量
GITLAB_PERSONAL_ACCESS_TOKEN: 您的 GitLab 个人访问令牌。GITLAB_API_URL: 您的 GitLab API URL。(默认值:https://gitlab.com/api/v4)GITLAB_READ_ONLY_MODE: 当设置为 'true' 时,限制服务器仅暴露只读操作。这在增强安全性或不需要写入权限时非常有用。对于与 Cursor 一起使用并受其 40 个工具限制的情况也很有用。
工具 🛠️
-
create_or_update_file- Create or update a single file in a GitLab project. 📝
- Inputs:
project_id(string): Project ID or namespace/project_pathfile_path(string): Path to create/update the filecontent(string): File contentcommit_message(string): Commit messagebranch(string): Branch to create/update the file inprevious_path(optional string): Previous file path when renaming a file
- Returns: File content and commit details
-
push_files- Push multiple files in a single commit. 📤
- Inputs:
project_id(string): Project ID or namespace/project_pathbranch(string): Branch to push tofiles(array): Array of files to push, each withfile_pathandcontentpropertiescommit_message(string): Commit message
- Returns: Updated branch reference
-
search_repositories- Search for GitLab projects. 🔍
- Inputs:
search(string): Search querypage(optional number): Page number (default: 1)per_page(optional number): Results per page (default: 20, max: 100)
- Returns: Project search results
-
create_repository- Create a new GitLab project. ➕
- Inputs:
name(string): Project namedescription(optional string): Project descriptionvisibility(optional string): Project visibility level (public, private, internal)initialize_with_readme(optional boolean): Initialize with README
- Returns: Details of the created project
-
get_file_contents- Get the contents of a file or directory. 📂
- Inputs:
project_id(string): Project ID or namespace/project_pathfile_path(string): Path to the file/directoryref(optional string): Branch, tag, or commit SHA (default: default branch)
- Returns: File/directory content
-
create_issue- Create a new issue. 🐛
- Inputs:
project_id(string): Project ID or namespace/project_pathtitle(string): Issue titledescription(string): Issue descriptionassignee_ids(optional number[]): Array of assignee IDsmilestone_id(optional number): Milestone IDlabels(optional string[]): Array of labels
- Returns: Details of the created issue
-
create_merge_request- Create a new merge request. 🚀
- Inputs:
project_id(string): Project ID or namespace/project_pathtitle(string): Merge request titledescription(string): Merge request descriptionsource_branch(string): Branch with changestarget_branch(string): Branch to merge intoallow_collaboration(optional boolean): Allow collaborators to push commits to the source branchdraft(optional boolean): Create as a draft merge request
- Returns: Details of the created merge request
-
fork_repository- Fork a project. 🍴
- Inputs:
project_id(string): Project ID or namespace/project_path to forknamespace(optional string): Namespace to fork into (default: user namespace)
- Returns: Details of the forked project
-
create_branch- Create a new branch. 🌿
- Inputs:
project_id(string): Project ID or namespace/project_pathname(string): New branch nameref(optional string): Ref to create the branch from (branch, tag, commit SHA, default: default branch)
- Returns: Created branch reference
-
get_merge_request- Get details of a merge request. ℹ️
- Inputs:
project_id(string): Project ID or namespace/project_pathmerge_request_iid(number): Merge request IID
- Returns: Merge request details
-
get_merge_request_diffs- Get changes (diffs) of a merge request. diff
- Inputs:
project_id(string): Project ID or namespace/project_pathmerge_request_iid(number): Merge request IIDview(optional string): Diff view type ('inline' or 'parallel')
- Returns: Array of merge request diff information
-
update_merge_request- Update a merge request. 🔄
- Inputs:
project_id(string): Project ID or namespace/project_pathmerge_request_iid(number): Merge request IIDtitle(optional string): New titledescription(string): New descriptiontarget_branch(optional string): New target branchstate_event(optional string): Merge request state change event ('close', 'reopen')remove_source_branch(optional boolean): Remove source branch after mergeallow_collaboration(optional boolean): Allow collaborators to push commits to the source branch
- Returns: Updated merge request details
-
create_note- Create a new note (comment) to an issue or merge request. 💬
- Inputs:
project_id(string): Project ID or namespace/project_pathnoteable_type(string): Type of noteable ("issue" or "merge_request")noteable_iid(number): IID of the issue or merge requestbody(string): Note content
- Returns: Details of the created note
-
list_projects- List accessible projects with rich filtering options 📊
- Inputs:
- Search/filtering:
searchownedmembershiparchivedvisibility
- Features filtering:
with_issues_enabledwith_merge_requests_enabled
- Sorting:
order_bysort
- Access control:
min_access_level
- Pagination:
pageper_pagesimple
- Search/filtering:
- Returns: Array of projects
-
list_labels- List all labels for a project with filtering options 🏷️
- Inputs:
project_id(string): Project ID or pathwith_counts(optional): Include issue and merge request countsinclude_ancestor_groups(optional): Include ancestor groupssearch(optional): Filter labels by keyword
- Returns: Array of labels
-
get_label- Get a single label from a project
- Inputs:
project_id(string): Project ID or pathlabel_id(number/string): Label ID or nameinclude_ancestor_groups(optional): Include ancestor groups
- Returns: label details
-
create_label- Create a new label in an object 🏷️➕
- Inputs:
project_id(string): Project ID or pathname(string): Label namecolor(string): Color in hex format (e.g., "#FF0000")description(optional): Label descriptionpriority(optional): Label priority
- Returns: Created label details
-
update_label- Update an existing label in a project 🏷️✏️
- Inputs:
project_id(string): Project ID or pathlabel_id(number/string): Label ID or namenew_name(optional): New label namecolor(optional): New color in hex formatdescription(optional): New descriptionpriority(optional): New priority
- Returns: Updated label details
-
delete_label- Delete a label from a project 🏷️❌
- Inputs:
project_id(string): Project ID or pathlabel_id(number/string): Label ID or name
- Returns: Success message
-
list_group_projects- List all projects in a GitLab group. 📂
- Inputs:
group_id(string): Project ID or namespace/project_path- Filtering options:
include_subgroups(optional boolean): Include projects from subgroupssearch(optional string): Search term to filter projectsarchived(optional boolean): Filter for archived projectsvisibility(optional string): Filter by project visibility (public/internal/private)with_programming_language(optional string): Filter by programming languagestarred(optional boolean): Filter by starred projects
- Feature filtering:
with_issues_enabled(optional boolean): Filter projects with issues feature enabledwith_merge_requests_enabled(optional boolean): Filter projects with merge requests feature enabledmin_access_level(optional number): Filter by minimum access level
- Pagination:
page(optional number): Page numberper_page(optional number): Results per page
- Sorting:
order_by(optional string): Field to sort bysort(optional string): Sort direction (asc/desc)
- Additional data:
statistics(optional boolean): Include project statisticswith_custom_attributes(optional boolean): Include custom attributeswith_security_reports(optional boolean): Include security reports
- Returns: List of projects
环境变量配置
在运行服务器之前,您需要设置以下环境变量:
GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token
GITLAB_API_URL=your_gitlab_api_url # Default: https://gitlab.com/api/v4
GITLAB_READ_ONLY_MODE=true # Optional: Enable read-only mode
许可证
MIT 许可证