gitlab-mcp-server
gitlab-mcp-server
MCP server for managing GitLab repositories — merge requests, pipelines, branches, and file operations — over the Model Context Protocol.
Features
Merge Requests — create, list, get, review diffs, and comment
Pipelines — list, get, retry, and cancel
Branches — create, delete, list, and inspect
Files — push (create/update/delete/move) and read file contents
Enterprise support — works with any GitLab instance (set
GITLAB_URL)
Installation
pip install gitlab-mcp-serverOr install from source:
git clone https://github.com/hhldiniz/gitlabmcp.git
cd gitlabmcp
pip install -e .For tests:
pip install -e ".[test]"Configuration
Set the following environment variables:
Variable | Required | Default | Description |
| Yes | — | GitLab Personal Access Token |
| No |
| GitLab instance URL |
Usage
Run as a standalone MCP server (stdio)
export GITLAB_TOKEN=glpat-your-token
python -m gitlab_mcp_serverConfigure with an MCP client
Add to your MCP client config (e.g. claude_desktop_config.json):
{
"mcpServers": {
"gitlab": {
"command": "python",
"args": ["-m", "gitlab_mcp_server"],
"env": {
"GITLAB_TOKEN": "glpat-your-token",
"GITLAB_URL": "https://gitlab.com"
}
}
}
}Tools
Tool | Description |
| Create a merge request |
| List merge requests (filter by state) |
| Get merge request details |
| Get MR diff/changes for code review |
| Add a note to a merge request |
| List pipelines (filter by ref) |
| Get pipeline details |
| Retry a failed pipeline |
| Cancel a running pipeline |
| Create a new branch from a ref |
| Delete a branch |
| List repository branches |
| Get branch details |
| Create/update/delete/move files in a single commit |
| Read a file from the repository |
Running Tests
python -m pytest tests -vProject Structure
gitlabmcp/
├── pyproject.toml
├── .env.example
├── client.py # Example MCP client
├── src/
│ └── gitlab_mcp_server/
│ ├── __init__.py
│ ├── __main__.py
│ ├── gitlab_client.py # GitLab API wrapper
│ ├── tools.py # MCP tool definitions + dispatch
│ └── server.py # MCP server (stdio transport)
└── tests/
├── conftest.py # Fixtures and mocks
├── test_gitlab_client.py
├── test_tools.py
└── test_server.py