GitLab MCP Server
Manage GitLab repos, issues, merge requests, and code from your AI assistant
The GitLab MCP Server connects Claude and other MCP-compatible agents directly to the GitLab API. Search repositories, open issues, create merge requests, read and write file contents, and manage branches — all from within your AI chat session. Works with both gitlab.com and self-hosted GitLab instances.
Installation & Configuration
Add this block to your claude_desktop_config.json (or your agent framework's MCP config file):
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-gitlab"],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "your_token_here",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
}
}
}
The GITLAB_API_URL environment variable is optional and defaults to https://gitlab.com/api/v4. Override it to point at your self-hosted instance.
Config file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json
Generate a Personal Access Token: GitLab → User Settings → Access Tokens → create a token with api scope (or read_api for read-only).
Available Tools (10)
create_or_update_filesearch_repositoriescreate_repositoryget_file_contentspush_filescreate_issuecreate_merge_requestfork_repositorycreate_branchlist_commits
Use Cases
- Merge request review — ask Claude to summarise open MRs and suggest approvals
- Issue triage — have agents label, comment on, and close GitLab issues automatically
- Branch & file management — create feature branches and commit scaffolded code in one shot
- Cross-project search — find code patterns or duplicated logic across all your GitLab repos
Gotchas
- Token scope matters: The
apiscope grants full read/write access. Useread_apiif you only need read operations — it's safer and still covers most use-cases. - Self-hosted URL: Forgetting to set
GITLAB_API_URLwhen using a self-hosted instance is the most common setup failure. The URL must end with/api/v4. - Group vs personal namespaces:
create_repositorycreates under your personal namespace by default. To create under a group, pass the full group path as the namespace. - Rate limits on gitlab.com: The REST API is throttled. Bulk operations (push_files across many repos) can hit 429s — add delays or batch carefully.
Security Note
A token with api scope can read and write to every repo in your account, create/delete branches, open MRs, and fork projects. Treat it like a password. Prefer a project-scoped token with the minimum required permissions, and never commit the token value to any repository.
Source & Documentation
GitHub Repository: https://github.com/modelcontextprotocol/servers/tree/main/src/gitlab
Protocol: Model Context Protocol (MCP) — modelcontextprotocol.io
20 ready-to-paste server configs + installer + doctor script