The GitLab MCP Server enables interaction with GitLab's API through the Model Context Protocol, allowing you to manage projects, manipulate files, and perform various GitLab operations directly from compatible clients like Claude Desktop or VS Code.
You'll need a GitLab Personal Access Token with appropriate permissions:
api
for full API accessread_api
for read-only accessread_repository
and write_repository
for repository operationsAdd the following to your claude_desktop_config.json
:
{
"mcpServers": {
"gitlab": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"GITLAB_PERSONAL_ACCESS_TOKEN",
"-e",
"GITLAB_API_URL",
"mcp/gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
}
}
}
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
}
}
}
For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code:
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "gitlab_token",
"description": "GitLab Personal Access Token",
"password": true
},
{
"type": "promptString",
"id": "gitlab_url",
"description": "GitLab API URL (optional)",
"default": "https://gitlab.com/api/v4"
}
],
"servers": {
"gitlab": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"mcp/gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "${input:gitlab_token}",
"GITLAB_API_URL": "${input:gitlab_url}"
}
}
}
}
}
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "gitlab_token",
"description": "GitLab Personal Access Token",
"password": true
},
{
"type": "promptString",
"id": "gitlab_url",
"description": "GitLab API URL (optional)",
"default": "https://gitlab.com/api/v4"
}
],
"servers": {
"gitlab": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-gitlab"
],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "${input:gitlab_token}",
"GITLAB_API_URL": "${input:gitlab_url}"
}
}
}
}
}
The server provides several tools to interact with GitLab:
Tool: create_or_update_file
Inputs:
- project_id: Project ID or URL-encoded path
- file_path: Path where to create/update the file
- content: Content of the file
- commit_message: Commit message
- branch: Branch to create/update the file in
- previous_path (optional): Path of the file to move/rename
Tool: push_files
Inputs:
- project_id: Project ID or URL-encoded path
- branch: Branch to push to
- files: Array of files to push, each with file_path and content
- commit_message: Commit message
Tool: get_file_contents
Inputs:
- project_id: Project ID or URL-encoded path
- file_path: Path to file/directory
- ref (optional): Branch/tag/commit to get contents from
Tool: search_repositories
Inputs:
- search: Search query
- page (optional): Page number for pagination
- per_page (optional): Results per page (default 20)
Tool: create_repository
Inputs:
- name: Project name
- description (optional): Project description
- visibility (optional): 'private', 'internal', or 'public'
- initialize_with_readme (optional): Initialize with README
Tool: fork_repository
Inputs:
- project_id: Project ID or URL-encoded path
- namespace (optional): Namespace to fork to
Tool: create_branch
Inputs:
- project_id: Project ID or URL-encoded path
- branch: Name for new branch
- ref (optional): Source branch/commit for new branch
Tool: create_issue
Inputs:
- project_id: Project ID or URL-encoded path
- title: Issue title
- description (optional): Issue description
- assignee_ids (optional): User IDs to assign
- labels (optional): Labels to add
- milestone_id (optional): Milestone ID
Tool: create_merge_request
Inputs:
- project_id: Project ID or URL-encoded path
- title: MR title
- description (optional): MR description
- source_branch: Branch containing changes
- target_branch: Branch to merge into
- draft (optional): Create as draft MR
- allow_collaboration (optional): Allow commits from upstream members
GITLAB_PERSONAL_ACCESS_TOKEN
: Your GitLab personal access token (required)GITLAB_API_URL
: Base URL for GitLab API (optional, defaults to https://gitlab.com/api/v4
)There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.