A Model Context Protocol (MCP) server that provides seamless integration with GitLab, enabling AI assistants to interact with GitLab projects, issues, merge requests, CI/CD pipelines, and more.
- Project Management: List, create, update, and delete GitLab projects
- Issue Tracking: Full CRUD operations for issues, including comments and state management
- Merge Requests: Create, review, approve, and merge pull requests with diff viewing
- Repository Operations: Branch management, file operations, commits, and tags
- CI/CD Integration: Pipeline and job management with logs and retry capabilities
- Group Management: Manage GitLab groups and group memberships
- User Management: Search and retrieve user information
- Labels & Milestones: Organize work with labels and milestones
- Field Filtering: Customize API responses to include only needed fields
- Pagination Support: Efficient handling of large result sets
- Comprehensive Error Handling: Clear, actionable error messages with recovery suggestions
- SSL Verification: Configurable SSL certificate verification for self-hosted instances
Install the GitLab MCP server using pip:
pip install gitlab-mcp-serverThe server requires the following environment variables:
-
GITLAB_TOKEN(required): Your GitLab Personal Access Token- Generate at: https://gitlab.com/-/profile/personal_access_tokens
- Required scopes:
api,read_user,read_repository,write_repository
-
GITLAB_URL(optional): GitLab instance URL- Default:
https://gitlab.com - For self-hosted:
https://gitlab.example.com
- Default:
-
GITLAB_VERIFY_SSL(optional): SSL certificate verification- Default:
true - Set to
falsefor self-signed certificates (not recommended for production)
- Default:
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gitlab": {
"command": "python",
"args": ["-m", "gitlab_mcp_server"],
"env": {
"GITLAB_TOKEN": "your-personal-access-token",
"GITLAB_URL": "https://gitlab.com",
"GITLAB_VERIFY_SSL": "true"
}
}
}
}For other MCP-compatible clients, use the following command:
python -m gitlab_mcp_serverWith environment variables set in your shell or passed directly:
GITLAB_TOKEN=your-token GITLAB_URL=https://gitlab.com python -m gitlab_mcp_server-
list_projects: List GitLab projects with pagination and search- Parameters:
per_page,page,search,include_fields
- Parameters:
-
get_project: Get details of a specific project- Parameters:
project_id,include_fields
- Parameters:
-
create_project: Create a new GitLab project- Parameters:
name,description,visibility,initialize_with_readme,include_fields
- Parameters:
-
update_project: Update an existing project- Parameters:
project_id,name,description,visibility,default_branch,include_fields
- Parameters:
-
delete_project: Delete a project- Parameters:
project_id
- Parameters:
-
list_issues: List issues in a project with filtering- Parameters:
project_id,per_page,page,state,labels,include_fields
- Parameters:
-
get_issue: Get details of a specific issue- Parameters:
project_id,issue_iid,include_fields
- Parameters:
-
create_issue: Create a new issue- Parameters:
project_id,title,description,labels,assignee_ids,include_fields
- Parameters:
-
update_issue: Update an existing issue- Parameters:
project_id,issue_iid,title,description,labels,assignee_ids,state_event,include_fields
- Parameters:
-
close_issue: Close an issue- Parameters:
project_id,issue_iid,include_fields
- Parameters:
-
reopen_issue: Reopen a closed issue- Parameters:
project_id,issue_iid,include_fields
- Parameters:
-
add_issue_comment: Add a comment to an issue- Parameters:
project_id,issue_iid,body
- Parameters:
-
list_issue_comments: List comments on an issue- Parameters:
project_id,issue_iid,per_page,page
- Parameters:
-
list_merge_requests: List merge requests in a project- Parameters:
project_id,per_page,page,state,include_fields
- Parameters:
-
get_merge_request: Get details of a specific merge request- Parameters:
project_id,mr_iid,include_fields
- Parameters:
-
create_merge_request: Create a new merge request- Parameters:
project_id,source_branch,target_branch,title,description,include_fields
- Parameters:
-
update_merge_request: Update an existing merge request- Parameters:
project_id,mr_iid,title,description,target_branch,state_event,include_fields
- Parameters:
-
merge_merge_request: Merge a merge request- Parameters:
project_id,mr_iid,merge_commit_message
- Parameters:
-
approve_merge_request: Approve a merge request- Parameters:
project_id,mr_iid
- Parameters:
-
get_merge_request_changes: Get diff/changes for a merge request- Parameters:
project_id,mr_iid
- Parameters:
-
add_merge_request_comment: Add a comment to a merge request- Parameters:
project_id,mr_iid,body
- Parameters:
-
list_merge_request_comments: List comments on a merge request- Parameters:
project_id,mr_iid,per_page,page
- Parameters:
-
list_branches: List branches in a repository- Parameters:
project_id,per_page,page,search,include_fields
- Parameters:
-
get_branch: Get details of a specific branch- Parameters:
project_id,branch,include_fields
- Parameters:
-
create_branch: Create a new branch- Parameters:
project_id,branch,ref,include_fields
- Parameters:
-
delete_branch: Delete a branch- Parameters:
project_id,branch
- Parameters:
-
get_file: Get a file from the repository- Parameters:
project_id,file_path,ref,include_fields
- Parameters:
-
create_file: Create a new file in the repository- Parameters:
project_id,file_path,branch,content,commit_message,encoding,include_fields
- Parameters:
-
update_file: Update an existing file- Parameters:
project_id,file_path,branch,content,commit_message,encoding,include_fields
- Parameters:
-
delete_file: Delete a file from the repository- Parameters:
project_id,file_path,branch,commit_message
- Parameters:
-
list_commits: List commits in a repository- Parameters:
project_id,per_page,page,ref_name,include_fields
- Parameters:
-
get_commit: Get details of a specific commit- Parameters:
project_id,sha,include_fields
- Parameters:
-
list_tags: List tags in a repository- Parameters:
project_id,per_page,page,include_fields
- Parameters:
-
create_tag: Create a new tag- Parameters:
project_id,tag_name,ref,message,include_fields
- Parameters:
-
list_pipelines: List CI/CD pipelines- Parameters:
project_id,per_page,page,ref,status,include_fields
- Parameters:
-
get_pipeline: Get details of a specific pipeline- Parameters:
project_id,pipeline_id,include_fields
- Parameters:
-
create_pipeline: Trigger a new pipeline- Parameters:
project_id,ref,variables,include_fields
- Parameters:
-
retry_pipeline: Retry a failed pipeline- Parameters:
project_id,pipeline_id
- Parameters:
-
cancel_pipeline: Cancel a running pipeline- Parameters:
project_id,pipeline_id
- Parameters:
-
list_jobs: List jobs in a pipeline- Parameters:
project_id,pipeline_id,per_page,page,include_fields
- Parameters:
-
get_job: Get details of a specific job- Parameters:
project_id,job_id,include_fields
- Parameters:
-
retry_job: Retry a failed job- Parameters:
project_id,job_id
- Parameters:
-
cancel_job: Cancel a running job- Parameters:
project_id,job_id
- Parameters:
-
get_job_log: Get logs for a job- Parameters:
project_id,job_id
- Parameters:
-
list_groups: List GitLab groups- Parameters:
per_page,page,search,include_fields
- Parameters:
-
get_group: Get details of a specific group- Parameters:
group_id,include_fields
- Parameters:
-
create_group: Create a new group- Parameters:
name,path,description,visibility,include_fields
- Parameters:
-
update_group: Update an existing group- Parameters:
group_id,name,path,description,visibility,include_fields
- Parameters:
-
delete_group: Delete a group- Parameters:
group_id
- Parameters:
-
list_group_members: List members of a group- Parameters:
group_id,per_page,page,include_fields
- Parameters:
-
add_group_member: Add a member to a group- Parameters:
group_id,user_id,access_level,expires_at
- Parameters:
-
get_current_user: Get current authenticated user details- Parameters:
include_fields
- Parameters:
-
get_user: Get details of a specific user- Parameters:
user_id,include_fields
- Parameters:
-
list_users: List GitLab users- Parameters:
per_page,page,include_fields
- Parameters:
-
search_users: Search for users- Parameters:
search,per_page,page,include_fields
- Parameters:
-
list_labels: List labels in a project- Parameters:
project_id,per_page,page,include_fields
- Parameters:
-
create_label: Create a new label- Parameters:
project_id,name,color,description,include_fields
- Parameters:
-
update_label: Update an existing label- Parameters:
project_id,label_id,name,color,description,include_fields
- Parameters:
-
delete_label: Delete a label- Parameters:
project_id,label_id
- Parameters:
-
list_milestones: List milestones in a project- Parameters:
project_id,per_page,page,state,include_fields
- Parameters:
-
create_milestone: Create a new milestone- Parameters:
project_id,title,description,due_date,start_date,include_fields
- Parameters:
-
update_milestone: Update an existing milestone- Parameters:
project_id,milestone_id,title,description,due_date,start_date,include_fields
- Parameters:
-
close_milestone: Close a milestone- Parameters:
project_id,milestone_id,include_fields
- Parameters:
# List all accessible projects
list_projects(per_page=20, page=1)
# Search for projects
list_projects(search="my-project")
# Get specific fields only
list_projects(include_fields="id,name,web_url")# Create a new issue
create_issue(
project_id=123,
title="Bug: Login not working",
description="Users cannot log in with valid credentials",
labels="bug,priority::high"
)
# Add a comment
add_issue_comment(
project_id=123,
issue_iid=42,
body="I've reproduced this issue on staging"
)
# Close the issue
close_issue(project_id=123, issue_iid=42)# Create a merge request
create_merge_request(
project_id=123,
source_branch="feature/new-login",
target_branch="main",
title="Add new login flow",
description="Implements OAuth2 authentication"
)
# Get the diff
get_merge_request_changes(project_id=123, mr_iid=15)
# Approve and merge
approve_merge_request(project_id=123, mr_iid=15)
merge_merge_request(project_id=123, mr_iid=15)# Get a file
get_file(
project_id=123,
file_path="src/main.py",
ref="main"
)
# Create a new file
create_file(
project_id=123,
file_path="docs/api.md",
branch="main",
content="# API Documentation\n\n...",
commit_message="Add API documentation"
)
# Update an existing file
update_file(
project_id=123,
file_path="README.md",
branch="main",
content="# Updated README\n\n...",
commit_message="Update README with new instructions"
)# Trigger a pipeline
create_pipeline(
project_id=123,
ref="main",
variables={"DEPLOY_ENV": "staging"}
)
# List pipeline jobs
list_jobs(project_id=123, pipeline_id=456)
# Get job logs
get_job_log(project_id=123, job_id=789)
# Retry a failed job
retry_job(project_id=123, job_id=789)- Python 3.10 or higher
- pip or uv package manager
- GitLab account with Personal Access Token
- Clone the repository:
git clone https://github.com/yourusername/gitlab-mcp-server.git
cd gitlab-mcp-server- Install dependencies:
pip install -e ".[dev]"- Set up environment variables:
export GITLAB_TOKEN="your-personal-access-token"
export GITLAB_URL="https://gitlab.com"- Run tests:
pytest- Run with coverage:
pytest --cov=gitlab_mcp_server --cov-report=html- Run linting:
pylint src/gitlab_mcp_server- Format code:
black src/gitlab_mcp_server testsgitlab-mcp-server/
├── src/
│ └── gitlab_mcp_server/
│ ├── __init__.py # Package initialization
│ ├── server.py # Main server implementation
│ └── errors.py # Error handling utilities
├── tests/
│ ├── test_*.py # Test files
│ └── conftest.py # Pytest configuration
├── README.md # This file
└── pyproject.toml # Project metadata
Contributions are welcome! Please follow these guidelines:
- Fork the repository and create a feature branch
- Write tests for new functionality
- Ensure all tests pass with
pytest - Follow code style using
blackandpylint - Update documentation for new features
- Submit a pull request with a clear description
- Follow PEP 8 guidelines
- Use type hints for function parameters and return values
- Write docstrings for all public functions and classes
- Keep functions focused and under 50 lines when possible
- Use meaningful variable and function names
- Write unit tests for all new functionality
- Maintain test coverage above 70%
- Use mocking for external API calls
- Test error handling and edge cases
- Use clear, descriptive commit messages
- Start with a verb (Add, Fix, Update, Remove)
- Reference issue numbers when applicable
If you discover a security vulnerability, please email security@example.com instead of using the issue tracker. We take security seriously and will respond promptly.
- Never commit tokens: Keep your
GITLAB_TOKENsecure and never commit it to version control - Use environment variables: Store sensitive configuration in environment variables
- Enable SSL verification: Only disable SSL verification for development/testing
- Rotate tokens regularly: Generate new Personal Access Tokens periodically
- Limit token scopes: Only grant necessary API scopes to your tokens
- Use read-only tokens: When possible, use tokens with read-only access
This project is licensed under the MIT License. See the LICENSE file for details.
- Issues: Report bugs and request features on GitHub Issues
- Discussions: Ask questions on GitHub Discussions
- Documentation: Full API documentation at docs.example.com
- Built with Model Context Protocol
- Uses httpx for HTTP requests
- Inspired by the GitLab API and community
See CHANGELOG.md for a detailed history of changes.
Made with ❤️ for the GitLab and AI community