MCP GitLab Server
Enables comprehensive GitLab integration allowing LLMs to manage projects, issues, merge requests, repository files, CI/CD pipelines, and perform batch operations. Supports advanced features like AI-optimized summaries, smart diffs, and atomic operations with rollback support.
README
MCP GitLab Server
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.
Features
Core Features
- 🔍 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 and history
- 💬 Discussions - Read and resolve merge request discussions
- 🎯 Smart Operations - Batch operations, AI summaries, and smart diffs
Advanced Features
- 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
Installation
Using uvx (recommended - no installation needed)
# Run directly without installation
uvx mcp-gitlab
From source
# 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 tests
Configuration
Environment Variables
Set 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"
Getting a GitLab Token
- 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)
Usage
With Claude Desktop
Add to your Claude Desktop configuration:
Using uvx (recommended - no installation needed):
{
"mcp-gitlab": {
"command": "uvx",
"args": ["mcp-gitlab"],
"env": {
"GITLAB_PRIVATE_TOKEN": "your-token-here"
}
}
}
Using uv (if you've cloned the repository):
{
"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.
Running with uvx
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
Standalone Usage
# If running from source (after uv sync)
uv run mcp-gitlab
# Or run the Python module directly
uv run python -m mcp_gitlab
Available Tools
Project Management
gitlab_list_projects
List accessible GitLab projects with pagination and search.
{
"owned": false,
"search": "my-project",
"per_page": 20,
"page": 1
}
gitlab_get_project
Get detailed information about a specific project.
{
"project_id": "group/project"
}
gitlab_get_current_project
Get the GitLab project information from the current git repository.
{
"path": "."
}
Issues
gitlab_list_issues
List project issues with state filtering.
{
"project_id": "group/project",
"state": "opened",
"per_page": 20
}
gitlab_get_issue
Get a single issue with full details.
{
"project_id": "group/project",
"issue_iid": 123
}
gitlab_add_issue_comment
Add a comment to an issue.
{
"project_id": "group/project",
"issue_iid": 123,
"body": "Thanks for reporting this!"
}
Merge Requests
gitlab_list_merge_requests
List merge requests with filtering options.
{
"project_id": "group/project",
"state": "opened"
}
gitlab_get_merge_request
Get detailed merge request information.
{
"project_id": "group/project",
"mr_iid": 456
}
gitlab_update_merge_request
Update merge request fields.
{
"project_id": "group/project",
"mr_iid": 456,
"title": "Updated title",
"description": "New description",
"labels": "bug,priority"
}
gitlab_merge_merge_request
Merge a merge request with options.
{
"project_id": "group/project",
"mr_iid": 456,
"squash": true,
"should_remove_source_branch": true
}
gitlab_approve_merge_request
Approve a merge request.
{
"project_id": "group/project",
"mr_iid": 456
}
Repository Operations
gitlab_get_file_content
Read file content from the repository.
{
"project_id": "group/project",
"file_path": "src/main.py",
"ref": "main"
}
gitlab_create_commit
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"
}
]
}
gitlab_compare_refs
Compare two branches, tags, or commits.
{
"project_id": "group/project",
"from_ref": "main",
"to_ref": "feature-branch"
}
Advanced Tools
gitlab_batch_operations
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}}"
}
}
]
}
gitlab_summarize_merge_request
Generate an AI-friendly summary of a merge request.
{
"project_id": "group/project",
"mr_iid": 456,
"max_length": 500
}
gitlab_smart_diff
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
}
Complete Tool List
- 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 - 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:
gitlab_list_pipelines,gitlab_summarize_pipeline - Search:
gitlab_search_projects,gitlab_search_in_project - Users:
gitlab_list_user_events,gitlab_list_project_members - 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
Examples
Auto-detect and List Issues
# 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"
})
Create a Fix with Batch Operations
# 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}}"
}
}
]
})
Development
Running Tests
# 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 -v
Code Style
The 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/
Troubleshooting
Authentication Issues
- Ensure your token has the required scopes (
api,read_repository,write_repository) - Check token expiration date
- Verify GitLab URL if using self-hosted instance
Rate Limiting
GitLab API has rate limits. The server handles rate limit errors gracefully and returns appropriate error messages.
Large Responses
Responses are automatically truncated if they exceed size limits. Use pagination parameters to retrieve data in chunks.
Contributing
- 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
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Acknowledgments
- Built on the Model Context Protocol
- Uses python-gitlab for GitLab API interaction
- Inspired by the need for better LLM-GitLab integration
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。