Overview
GitLab MCP Server is an API that enables project management and file operations through the GitLab platform. It facilitates various Git-related tasks using a user-friendly interface.
To use the GitLab MCP Server, create a Personal Access Token on GitLab, configure your Claude Desktop application to include your token and GitLab API URL, and employ the various API endpoints for specific tasks like creating projects and managing files.
- Automatic Branch Creation: Automatically creates branches if they do not exist during file operations. - Comprehensive Error Handling: Provides clear error messages for common issues encountered. - Git History Preservation: Maintains Git history accurately without the need for force pushing. - Batch Operations Support: Allows both single-file and multi-file operations.
- Managing GitLab project repositories programmatically.
- Automating file creation and updates across multiple GitLab projects.
- Facilitating team collaboration through issue and merge request management.
Add to your AI client
Use these steps to connect GitLab in Cursor, Claude, VS Code, and other MCP-compatible apps. The same JSON appears in the Use with menu above for one-click copy.
Cursor
Add this to your .cursor/mcp.json file in your project root, then restart Cursor.
.cursor/mcp.json
{
"mcpServers": {
"gitlab-modelcontextprotocol": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_API_URL": "https://gitlab.com/api/v4",
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}Claude Desktop
Add this server entry to the mcpServers object in your Claude Desktop config, then restart the app.
~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
{
"mcpServers": {
"gitlab-modelcontextprotocol": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_API_URL": "https://gitlab.com/api/v4",
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}Claude Code
Add this to your project's .mcp.json file. Claude Code will detect it automatically.
.mcp.json (project root)
{
"mcpServers": {
"gitlab-modelcontextprotocol": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_API_URL": "https://gitlab.com/api/v4",
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}VS Code (Copilot)
Add this to your .vscode/mcp.json file. Requires the GitHub Copilot extension with MCP support enabled.
.vscode/mcp.json
{
"servers": {
"gitlab-modelcontextprotocol": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_API_URL": "https://gitlab.com/api/v4",
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}Windsurf
Add this to your Windsurf MCP config file, then restart Windsurf.
~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"gitlab-modelcontextprotocol": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_API_URL": "https://gitlab.com/api/v4",
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}Cline
Open Cline settings, navigate to MCP Servers, and add this server configuration.
Cline MCP Settings (via UI)
{
"mcpServers": {
"gitlab-modelcontextprotocol": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_API_URL": "https://gitlab.com/api/v4",
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}FAQ
How do I create a Personal Access Token?
Visit User Settings > Access Tokens in GitLab to generate a token with the necessary scopes.
Is there a limit on the number of operations I can perform?
There may be rate limits based on your GitLab account type. Monitor your API usage to avoid exceeding limits.
Can I use GitLab MCP Server for self-hosted GitLab instances?
Yes! You can configure the `GITLAB_API_URL` environment variable to point to your self-hosted instance.