Overview
GitLab MCP Server provides a standardized interface between LLMs and GitLab's robust API ecosystem. This reference implementation allows AI systems to manage repositories, handle files, create issues, and perform other GitLab operations through a structured protocol. The server maintains Git best practices while offering automated workflows to simplify complex operations, making it ideal for developers looking to integrate GitLab functionality into AI-assisted workflows.
Features
- Automatic Branch Creation: Creates branches on-demand when pushing changes
- Comprehensive Error Handling: Provides clear error messages for troubleshooting
- Git History Preservation: Maintains proper commit history without force pushing
- Batch Operations: Supports both single-file and multi-file operations
- Project Management: Enables repository, issue, and merge request management
- File Manipulation: Allows reading, creating, and updating repository files
- Multi-environment Support: Works with both gitlab.com and self-hosted instances
Use cases
- Automating repository creation and configuration
- Building AI-assisted code management workflows
- Implementing automated documentation updates
- Creating issue tracking and management systems
- Enabling file operations across multiple repositories
- Streamlining merge request processes
- Developing GitLab-integrated development assistants
- Automating repository forking and contribution workflows
Tools
create_or_update_file
: Creates or updates files with proper Git commitspush_files
: Pushes multiple files in a single commitsearch_repositories
: Searches GitLab projects with paginationcreate_repository
: Creates new GitLab projects with customizable settingsget_file_contents
: Retrieves file or directory contentscreate_issue
: Creates project issues with configurable propertiescreate_merge_request
: Initiates merge requests between branchesfork_repository
: Forks existing repositories to specified namespacescreate_branch
: Creates new branches from existing references
Integration complexity
3/5 - Moderate complexity requiring GitLab token setup and configuration choices.
Setup Guide
Prerequisites
- Create a GitLab Personal Access Token with appropriate permissions:
- Go to User Settings > Access Tokens in GitLab
- Select required scopes (
api
,read_repository
,write_repository
) - Create and securely store your token
Docker Configuration
Add to your 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": "<YOUR_TOKEN>",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
}
}
}
NPX Configuration
Add to your claude_desktop_config.json
:
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
}
}
}
Building From Source
To build a Docker image:
docker build -t mcp/gitlab -f src/gitlab/Dockerfile .
License
MIT License