A Model Context Protocol (MCP) server that provides comprehensive GitLab API integration. This server enables LLMs to interact with GitLab repositories, manage merge requests, issues, and perform various Git operations.
- 🔐 Authentication & Users - Get current user info and lookup user profiles
- 🔍 Project Management - List, search, and get details about GitLab projects
- 📝 Issues - List, read, search, and comment on issues
- 🔀 Merge Requests - List, read, update, approve, and merge MRs
- 📁 Repository Files - Browse, read, and commit changes to files
- 🌳 Branches & Tags - List and manage branches and tags
- 🔧 CI/CD Pipelines - View pipeline status, jobs, and artifacts
- 💬 Discussions - Read and resolve merge request discussions
- 🎯 Smart Operations - Batch operations, AI summaries, and smart diffs
- Batch Operations - Execute multiple GitLab operations atomically with rollback support
- AI-Optimized Summaries - Generate concise summaries of MRs, issues, and pipelines
- Smart Diffs - Get structured diffs with configurable context and size limits
- Safe Preview - Preview file changes before committing
- Cross-Reference Support - Reference results from previous operations in batch mode
# Run directly without installation
uvx mcp-gitlab# Clone the repository
git clone https://github.com/Vijay-Duke/mcp-gitlab.git
cd mcp-gitlab
# Install dependencies and run with uv
uv sync
uv run mcp-gitlab
# Or install in development mode with test dependencies
uv sync --all-extras
uv run pytest # to run testsSet one of the following authentication tokens:
# Private token (recommended for personal use)
export GITLAB_PRIVATE_TOKEN="your-private-token"
# OAuth token
export GITLAB_OAUTH_TOKEN="your-oauth-token"
# GitLab URL (optional, defaults to https://gitlab.com)
export GITLAB_URL="https://gitlab.example.com"- Go to your GitLab profile settings
- Navigate to "Access Tokens"
- Create a new token with the following scopes:
api- Full API accessread_repository- Read repository contentwrite_repository- Write repository content (for commits)
Add to your Claude Desktop configuration:
{
"mcp-gitlab": {
"command": "uvx",
"args": ["mcp-gitlab"],
"env": {
"GITLAB_PRIVATE_TOKEN": "your-token-here"
}
}
}{
"mcp-gitlab": {
"command": "uv",
"args": ["run", "mcp-gitlab"],
"cwd": "/path/to/mcp-gitlab",
"env": {
"GITLAB_PRIVATE_TOKEN": "your-token-here"
}
}
}Replace /path/to/mcp-gitlab with the full path to where you cloned the repository.
The easiest way to run the MCP GitLab server is using uvx:
# Set your GitLab token
export GITLAB_PRIVATE_TOKEN="your-token-here"
# Run the server directly with uvx
uvx mcp-gitlab# If running from source (after uv sync)
uv run mcp-gitlab
# Or run the Python module directly
uv run python -m mcp_gitlabGet the currently authenticated user's profile information.
{}Returns comprehensive information including:
- Basic info: ID, username, name, email
- Profile details: bio, organization, job title
- Account status: state, creation date, admin status
- Permissions: can_create_group, can_create_project
- Security: two_factor_enabled, external status
Get details for a specific user by ID or username.
{
"user_id": 12345
}or
{
"username": "johndoe"
}Returns user information including:
- Basic info: ID, username, name
- Profile: avatar_url, web_url, bio
- Organization details: company, job title
- Account status and creation date
List accessible GitLab projects with pagination and search.
{
"owned": false,
"search": "my-project",
"per_page": 20,
"page": 1
}Get detailed information about a specific project.
{
"project_id": "group/project"
}Get the GitLab project information from the current git repository.
{
"path": "."
}List project issues with state filtering.
{
"project_id": "group/project",
"state": "opened",
"per_page": 20
}Get a single issue with full details.
{
"project_id": "group/project",
"issue_iid": 123
}Add a comment to an issue.
{
"project_id": "group/project",
"issue_iid": 123,
"body": "Thanks for reporting this!"
}List merge requests with filtering options.
{
"project_id": "group/project",
"state": "opened"
}Get detailed merge request information.
{
"project_id": "group/project",
"mr_iid": 456
}Update merge request fields.
{
"project_id": "group/project",
"mr_iid": 456,
"title": "Updated title",
"description": "New description",
"labels": "bug,priority"
}Merge a merge request with options.
{
"project_id": "group/project",
"mr_iid": 456,
"squash": true,
"should_remove_source_branch": true
}Approve a merge request.
{
"project_id": "group/project",
"mr_iid": 456
}Read file content from the repository.
{
"project_id": "group/project",
"file_path": "src/main.py",
"ref": "main"
}Create a commit with multiple file changes.
{
"project_id": "group/project",
"branch": "feature-branch",
"commit_message": "Add new features",
"actions": [
{
"action": "create",
"file_path": "new_file.py",
"content": "print('Hello')"
},
{
"action": "update",
"file_path": "existing.py",
"content": "# Updated content"
}
]
}Compare two branches, tags, or commits.
{
"project_id": "group/project",
"from_ref": "main",
"to_ref": "feature-branch"
}List jobs in a specific CI/CD pipeline.
{
"project_id": "group/project",
"pipeline_id": 789,
"per_page": 20,
"page": 1
}List jobs for a project with optional scope filtering.
{
"project_id": "group/project",
"scope": "failed",
"per_page": 25
}Get information about job artifacts (security note: content not downloaded).
{
"project_id": "group/project",
"job_id": 456,
"artifact_path": "build.zip"
}Execute multiple operations atomically with rollback support.
{
"project_id": "group/project",
"operations": [
{
"name": "get_issue",
"tool": "gitlab_get_issue",
"arguments": {"issue_iid": 123}
},
{
"name": "create_mr",
"tool": "gitlab_create_merge_request",
"arguments": {
"source_branch": "fix-{{get_issue.iid}}",
"target_branch": "main",
"title": "Fix: {{get_issue.title}}"
}
}
]
}Generate an AI-friendly summary of a merge request.
{
"project_id": "group/project",
"mr_iid": 456,
"max_length": 500
}Get a structured diff with context and size limits.
{
"project_id": "group/project",
"from_ref": "main",
"to_ref": "feature",
"context_lines": 3,
"max_file_size": 50000
}Search for GitLab users by name, username, or email.
{
"search": "John",
"per_page": 10
}Get comprehensive user profile and metadata.
{
"username": "johndoe"
}Get the current authenticated user's complete profile.
{}Summarize user's recent contributions across issues, MRs, and commits.
{
"username": "johndoe",
"since": "2024-01-01",
"until": "2024-01-31"
}Retrieve user's complete activity/events timeline.
{
"username": "johndoe",
"target_type": "Issue",
"after": "2024-01-01"
}Get all open merge requests authored by a user.
{
"username": "johndoe",
"sort": "updated"
}Get MRs where user is assigned as reviewer with pending action.
{
"username": "johndoe",
"priority": "high",
"sort": "urgency"
}Get open issues assigned to a user, prioritized by severity/SLA.
{
"username": "johndoe",
"sla_status": "overdue",
"sort": "priority"
}Get issues reported/created by a user.
{
"username": "johndoe",
"state": "opened",
"since": "2024-01-01"
}Get issues closed/resolved by a user.
{
"username": "johndoe",
"since": "2024-01-01",
"until": "2024-03-31"
}Get commits authored by a user within date range or branch.
{
"username": "johndoe",
"branch": "main",
"since": "2024-01-01",
"include_stats": true
}- Projects:
gitlab_list_projects,gitlab_get_project,gitlab_get_current_project,gitlab_search_projects - Issues:
gitlab_list_issues,gitlab_get_issue,gitlab_add_issue_comment,gitlab_summarize_issue - Merge Requests:
gitlab_list_merge_requests,gitlab_get_merge_request,gitlab_update_merge_request,gitlab_close_merge_request,gitlab_merge_merge_request,gitlab_add_merge_request_comment,gitlab_get_merge_request_notes,gitlab_approve_merge_request,gitlab_get_merge_request_approvals,gitlab_get_merge_request_discussions,gitlab_resolve_discussion,gitlab_get_merge_request_changes,gitlab_rebase_merge_request - Repository:
gitlab_get_file_content,gitlab_list_repository_tree,gitlab_list_commits,gitlab_get_commit,gitlab_get_commit_diff,gitlab_create_commit,gitlab_cherry_pick_commit,gitlab_compare_refs,gitlab_list_tags - Branches:
gitlab_list_branches - Pipelines & Jobs:
gitlab_list_pipelines,gitlab_list_pipeline_jobs,gitlab_list_project_jobs,gitlab_download_job_artifact,gitlab_summarize_pipeline - Search:
gitlab_search_projects,gitlab_search_in_project - Users:
gitlab_get_current_user,gitlab_get_user,gitlab_list_user_events,gitlab_list_project_members - User & Profile:
gitlab_search_user,gitlab_get_user_details,gitlab_get_my_profile,gitlab_get_user_contributions_summary,gitlab_get_user_activity_feed - User's Issues & MRs:
gitlab_get_user_open_mrs,gitlab_get_user_review_requests,gitlab_get_user_open_issues,gitlab_get_user_reported_issues,gitlab_get_user_resolved_issues - User's Code & Commits:
gitlab_get_user_commits - Releases:
gitlab_list_releases - Webhooks:
gitlab_list_project_hooks - AI Tools:
gitlab_summarize_merge_request,gitlab_summarize_issue,gitlab_summarize_pipeline - Advanced:
gitlab_batch_operations,gitlab_smart_diff,gitlab_safe_preview_commit
# First get current project from git repo
project = await session.call_tool("gitlab_get_current_project")
# Then list open issues
issues = await session.call_tool("gitlab_list_issues", {
"state": "opened"
})# Atomically: get issue → create branch → commit fix → create MR
result = await session.call_tool("gitlab_batch_operations", {
"operations": [
{
"name": "issue",
"tool": "gitlab_get_issue",
"arguments": {"issue_iid": 123}
},
{
"name": "fix",
"tool": "gitlab_create_commit",
"arguments": {
"branch": "fix-issue-{{issue.iid}}",
"commit_message": "Fix: {{issue.title}}",
"actions": [{
"action": "update",
"file_path": "src/bug.py",
"content": "# Fixed code here"
}]
}
},
{
"name": "mr",
"tool": "gitlab_create_merge_request",
"arguments": {
"source_branch": "fix-issue-{{issue.iid}}",
"target_branch": "main",
"title": "Fix: {{issue.title}}",
"description": "Fixes #{{issue.iid}}"
}
}
]
})# Install development dependencies
make install-dev
# Run all checks locally
make ci-local
# Format code
make format
# Run tests with coverage
make test-covThis project uses GitHub Actions for continuous integration and deployment:
-
CI Pipeline: Runs on every push and PR
- Linting (Ruff, Black, isort, MyPy)
- Testing (pytest with coverage)
- Security scanning (Bandit, Safety, pip-audit)
- Multi-version Python testing (3.10, 3.11, 3.12)
-
Code Quality:
- SonarCloud analysis
- CodeQL security analysis
- Complexity metrics (Radon, Xenon)
-
Release Pipeline: Automated releases on version tags
- PyPI package publishing
- Docker image building and publishing
- GitHub release creation
# Run all tests
uv run pytest tests/ -v
# Run with coverage
uv run pytest tests/ --cov=mcp_gitlab
# Run specific test file
uv run pytest tests/test_gitlab_client.py -vThe project uses:
- Black for code formatting
- isort for import sorting
- flake8 for linting
- mypy for type checking
# Format code
black src/ tests/
isort src/ tests/
# Run linters
flake8 src/ tests/
mypy src/- Ensure your token has the required scopes (
api,read_repository,write_repository) - Check token expiration date
- Verify GitLab URL if using self-hosted instance
GitLab API has rate limits. The server handles rate limit errors gracefully and returns appropriate error messages.
Responses are automatically truncated if they exceed size limits. Use pagination parameters to retrieve data in chunks.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Built on the Model Context Protocol
- Uses python-gitlab for GitLab API interaction
- Inspired by the need for better LLM-GitLab integration