Integrate with GitLab for Code Management
Archived official MCP reference server for GitLab: files, issues and merge requests via nine tools, against GitLab.com or self-hosted instances.
1.0.0Add to Favorites
Why it matters
Streamline your development lifecycle by integrating directly with GitLab. Manage projects, code, and merge requests programmatically to automate common tasks.
Outcomes
What it gets done
Create and update files within GitLab projects.
Automate the creation of merge requests and branches.
Search for repositories and create new projects.
Manage issues, including assignment and labeling.
Source
Get it from source
Spark does not host a copy of it.
Open sourceReports
Agent outcome reports
No reports yet
Capabilities
Tools your agent gets
Create or update a single file in a project.
Push multiple files in a single commit.
Search for GitLab projects.
Create a new GitLab project.
Get contents of a file or directory.
Create a new issue with title, description, assignees, and labels.
Create a new merge request between branches.
Fork a project to your namespace.
Create a new branch from a source ref.
Overview
GitLab MCP
An MCP server for GitLab - file operations, issue and merge-request management, repository search, and branch/fork management, working against GitLab.com or self-hosted instances. Use it when an AI assistant needs to operate on GitLab projects directly, not for GitHub integration.
What it does
This MCP server provides comprehensive integration with GitLab's API, enabling project management, file operations, and merge requests directly from an AI assistant. Features include automatic branch creation (branches are created automatically if they don't exist when creating/updating files or pushing changes), comprehensive error handling with clear messages for common issues, Git history preservation without force-pushing, and batch operations supporting both single-file and multi-file changes. This server is one of the official Model Context Protocol reference implementations, now maintained in the modelcontextprotocol/servers-archived repository and no longer receiving updates.
When to use - and when NOT to
Use it when an AI assistant needs to read or write GitLab project files, manage issues and merge requests, or search, fork, and branch GitLab repositories. It works against both GitLab.com and self-hosted GitLab instances by pointing GITLAB_API_URL at the instance's own API endpoint (defaulting to https://gitlab.com/api/v4). It is not a GitHub integration - it is scoped specifically to the GitLab API.
Capabilities
Nine tools are exposed: create_or_update_file (create or update a single file, with an optional previous_path to move/rename), push_files (push multiple files in one commit), search_repositories, create_repository (name, description, private/internal/public visibility, and an option to initialize with a README), get_file_contents (from a specific branch/tag/commit ref), create_issue (title, description, assignee IDs, labels, milestone), create_merge_request (source/target branch, draft flag, allow-collaboration flag), fork_repository (optionally to a named namespace), and create_branch (from a source ref).
How to install
Create a GitLab Personal Access Token scoped to api (full access), read_api (read-only), or read_repository/write_repository (repository operations only), depending on which tools you need. Add it to claude_desktop_config.json via Docker:
{
"mcpServers": {
"gitlab": {
"command": "docker",
"args": ["run", "--rm", "-i", "-e", "GITLAB_PERSONAL_ACCESS_TOKEN", "-e", "GITLAB_API_URL", "mcp/gitlab"],
"env": { "GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>", "GITLAB_API_URL": "https://gitlab.com/api/v4" }
}
}
}
Or via npx, with @modelcontextprotocol/server-gitlab as the args and the same two env vars. VS Code has one-click install buttons for both variants, or manual setup via .vscode/mcp.json with token/URL prompted as inputs rather than hardcoded - the token prompt is marked password: true so it isn't shown in plain text. The Docker image can be built locally with docker build -t vonwig/gitlab:mcp -f src/gitlab/Dockerfile .. Only GITLAB_PERSONAL_ACCESS_TOKEN is required; GITLAB_API_URL is optional. The server itself is MIT-licensed.
Who it's for
Developers whose AI assistant needs to manage GitLab projects, files, issues, and merge requests directly - against GitLab.com or a self-hosted instance.
Source README
GitLab MCP Server
MCP Server for the GitLab API, enabling project management, file operations, and more.
Features
- Automatic Branch Creation: When creating/updating files or pushing changes, branches are automatically created if they don't exist
- Comprehensive Error Handling: Clear error messages for common issues
- Git History Preservation: Operations maintain proper Git history without force pushing
- Batch Operations: Support for both single-file and multi-file operations
Tools
create_or_update_file- Create or update a single file in a project
- Inputs:
project_id(string): Project ID or URL-encoded pathfile_path(string): Path where to create/update the filecontent(string): Content of the filecommit_message(string): Commit messagebranch(string): Branch to create/update the file inprevious_path(optional string): Path of the file to move/rename
- Returns: File content and commit details
push_files- Push multiple files in a single commit
- Inputs:
project_id(string): Project ID or URL-encoded pathbranch(string): Branch to push tofiles(array): Files to push, each withfile_pathandcontentcommit_message(string): Commit message
- Returns: Updated branch reference
search_repositories- Search for GitLab projects
- Inputs:
search(string): Search querypage(optional number): Page number for paginationper_page(optional number): Results per page (default 20)
- Returns: Project search results
create_repository- Create a new GitLab project
- Inputs:
name(string): Project namedescription(optional string): Project descriptionvisibility(optional string): 'private', 'internal', or 'public'initialize_with_readme(optional boolean): Initialize with README
- Returns: Created project details
get_file_contents- Get contents of a file or directory
- Inputs:
project_id(string): Project ID or URL-encoded pathfile_path(string): Path to file/directoryref(optional string): Branch/tag/commit to get contents from
- Returns: File/directory contents
create_issue- Create a new issue
- Inputs:
project_id(string): Project ID or URL-encoded pathtitle(string): Issue titledescription(optional string): Issue descriptionassignee_ids(optional number[]): User IDs to assignlabels(optional string[]): Labels to addmilestone_id(optional number): Milestone ID
- Returns: Created issue details
create_merge_request- Create a new merge request
- Inputs:
project_id(string): Project ID or URL-encoded pathtitle(string): MR titledescription(optional string): MR descriptionsource_branch(string): Branch containing changestarget_branch(string): Branch to merge intodraft(optional boolean): Create as draft MRallow_collaboration(optional boolean): Allow commits from upstream members
- Returns: Created merge request details
fork_repository- Fork a project
- Inputs:
project_id(string): Project ID or URL-encoded pathnamespace(optional string): Namespace to fork to
- Returns: Forked project details
create_branch- Create a new branch
- Inputs:
project_id(string): Project ID or URL-encoded pathbranch(string): Name for new branchref(optional string): Source branch/commit for new branch
- Returns: Created branch reference
Setup
Personal Access Token
Create a GitLab Personal Access Token with appropriate permissions:
- Go to User Settings > Access Tokens in GitLab
- Select the required scopes:
apifor full API accessread_apifor read-only accessread_repositoryandwrite_repositoryfor repository operations
- Create the token and save it securely
Usage with Claude Desktop
Add the following to your claude_desktop_config.json:
Docker
{
"mcpServers": {
"gitlab": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"GITLAB_PERSONAL_ACCESS_TOKEN",
"-e",
"GITLAB_API_URL",
"mcp/gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>",
"GITLAB_API_URL": "https://gitlab.com/api/v4" // Optional, for self-hosted instances
}
}
}
}
NPX
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>",
"GITLAB_API_URL": "https://gitlab.com/api/v4" // Optional, for self-hosted instances
}
}
}
}
Usage with VS Code
For quick installation, use one of the one-click installation buttons below...
For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open User Settings (JSON).
Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.
Note that the
mcpkey is not needed in the.vscode/mcp.jsonfile.
Docker
{
"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}"
}
}
}
}
}
NPX
{
"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}"
}
}
}
}
}
Build
Docker build:
docker build -t vonwig/gitlab:mcp -f src/gitlab/Dockerfile .
Environment Variables
GITLAB_PERSONAL_ACCESS_TOKEN: Your GitLab personal access token (required)GITLAB_API_URL: Base URL for GitLab API (optional, defaults tohttps://gitlab.com/api/v4)
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.