GitLab MCP server

  • Tier: Premium, Ultimate
  • Add-on: GitLab Duo Core, Pro, or Enterprise
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
  • Status: Beta

To provide feedback on this feature, leave a comment on issue 561564.

With the GitLab Model Context Protocol (MCP) server, you can securely connect AI tools and applications to your GitLab instance. AI assistants like Claude Desktop, Claude Code, Cursor, and other MCP-compatible tools can then access your GitLab data and perform actions on your behalf.

The GitLab MCP server provides a standardized way for AI tools to:

  • Access GitLab project information.
  • Retrieve issue and merge request data.
  • Interact with GitLab APIs securely.
  • Perform GitLab-specific operations through AI assistants.

The GitLab MCP server supports OAuth 2.0 Dynamic Client Registration, which enables AI tools to register themselves with your GitLab instance. When an AI tool connects to your GitLab MCP server for the first time, it:

  1. Registers itself as an OAuth application.
  2. Requests authorization to access your GitLab data.
  3. Receives an access token for secure API access.

For a click-through demo, see GitLab Duo Agent Platform - GitLab MCP server.

Prerequisites

Connect a client to the GitLab MCP server

The GitLab MCP server supports two transport types:

  • HTTP transport (recommended): Direct connection without additional dependencies.
  • stdio transport with mcp-remote: Connection through a proxy (requires Node.js).

Common AI tools support the JSON configuration format for the mcpServers key and provide different methods to configure the GitLab MCP server settings.

To configure the GitLab MCP server by using HTTP transport, use this format:

  • Replace <gitlab.example.com> with:
    • On GitLab Self-Managed, your GitLab instance URL.
    • On GitLab.com, gitlab.com.
{
  "mcpServers": {
    "GitLab": {
      "type": "http",
      "url": "https://<gitlab.example.com>/api/v4/mcp"
    }
  }
}

stdio transport with mcp-remote

Prerequisites:

  • Install Node.js version 20 or later.

To configure the GitLab MCP server by using stdio transport, use this format:

  • For the "command": parameter, if npx is installed locally instead of globally, provide the full path to npx.
  • Replace <gitlab.example.com> with:
    • On GitLab Self-Managed, your GitLab instance URL.
    • On GitLab.com, gitlab.com.
{
  "mcpServers": {
    "GitLab": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://<gitlab.example.com>/api/v4/mcp"
      ]
    }
  }
}

Connect Cursor to the GitLab MCP server

Cursor uses HTTP transport for direct connection without additional dependencies. To configure the GitLab MCP server in Cursor:

  1. In Cursor, go to Settings > Cursor Settings > Tools & MCP.

  2. Under Installed MCP Servers, select New MCP Server.

  3. Add this definition to the mcpServers key in the opened mcp.json file:

    • Replace <gitlab.example.com> with:
      • On GitLab Self-Managed, your GitLab instance URL.
      • On GitLab.com, gitlab.com.
    {
      "mcpServers": {
        "GitLab": {
           "type": "http",
           "url": "https://<gitlab.example.com>/api/v4/mcp"
        }
      }
    }
  4. Save the file, and wait for your browser to open the OAuth authorization page.

    If this does not happen, close and restart Cursor.

  5. In your browser, review and approve the authorization request.

You can now start a new chat and ask a question depending on the available tools.

You’re responsible for guarding against prompt injection when you use these tools. Exercise extreme caution or use MCP tools only on GitLab objects you trust.

Connect Claude Code to the GitLab MCP server

Claude Code uses HTTP transport for direct connection without additional dependencies. To configure the GitLab MCP server in Claude Code:

  1. In your terminal, add the GitLab MCP server with the CLI:

    • Replace <gitlab.example.com> with:
      • On GitLab Self-Managed, your GitLab instance URL.
      • On GitLab.com, gitlab.com.
    claude mcp add --transport http GitLab https://<gitlab.example.com>/api/v4/mcp
  2. Start Claude Code:

    claude
  3. Authenticate with the GitLab MCP server:

    • In the chat, type /mcp.
    • From the list, select your GitLab server.
    • In your browser, review and approve the authorization request.
  4. Optional. To verify the connection, type /mcp again. Your GitLab server should appear as connected.

You can now start a new chat and ask a question depending on the available tools.

You’re responsible for guarding against prompt injection when you use these tools. Exercise extreme caution or use MCP tools only on GitLab objects you trust.

Connect Claude Desktop to the GitLab MCP server

Prerequisites:

  • Install Node.js version 20 or later.
  • Ensure Node.js is available globally in the PATH environment variable (which -a node).

To configure the GitLab MCP server in Claude Desktop:

  1. Open Claude Desktop.

  2. Edit the configuration file. You can do either of the following:

    • In Claude Desktop, go to Settings > Developer > Edit Config.
    • On macOS, open the ~/Library/Application Support/Claude/claude_desktop_config.json file.
  3. Add this entry for the GitLab MCP server, editing as needed:

    • For the "command": parameter, if npx is installed locally instead of globally, provide the full path to npx.
    • Replace <gitlab.example.com> with:
      • On GitLab Self-Managed, your GitLab instance URL.
      • On GitLab.com, GitLab.com.
    {
      "mcpServers": {
        "GitLab": {
          "command": "npx",
          "args": [
            "-y",
            "mcp-remote",
            "https://<gitlab.example.com>/api/v4/mcp"
          ]
        }
      }
    }
  4. Save the configuration and restart Claude Desktop.

  5. On first connect, Claude Desktop opens a browser window for OAuth. Review and approve the request.

  6. Go to Settings > Developer and verify the new GitLab MCP configuration.

  7. Go to Settings > Connectors and inspect the connected GitLab MCP server.

You can now start a new chat and ask a question depending on the available tools.

You’re responsible for guarding against prompt injection when you use these tools. Exercise extreme caution or use MCP tools only on GitLab objects you trust.

Connect Gemini Code Assist and Gemini CLI to the GitLab MCP server

Gemini Code Assist and Gemini CLI use HTTP transport for direct connection without additional dependencies. To configure the GitLab MCP server in Gemini Code Assist or Gemini CLI:

  1. Edit ~/.gemini/settings.json and add the GitLab MCP server.

    • Replace <gitlab.example.com> with:
      • On GitLab Self-Managed, your GitLab instance URL.
      • On GitLab.com, gitlab.com.
    {
      "mcpServers": {
        "GitLab": {
          "httpUrl": "https://<gitlab.example.com>/api/v4/mcp"
        }
      }
    }
  2. In Gemini Code Assist or Gemini CLI, run the /mcp auth GitLab command.

    The OAuth authorization page should appear. Otherwise, restart Gemini Code Assist or Gemini CLI.

  3. In your browser, review and approve the authorization request.

You can now start a new chat and ask a question depending on the available tools.

You’re responsible for guarding against prompt injection when you use these tools. Exercise extreme caution or use MCP tools only on GitLab objects you trust.

Connect GitHub Copilot in VS Code to the GitLab MCP server

GitHub Copilot uses HTTP transport for direct connection without additional dependencies. To configure the GitLab MCP server in GitHub Copilot in VS Code:

  1. In VS Code, open the Command Palette:

    • On macOS, press Command+ShiftP.
    • On Windows or Linux, press Control+ShiftP.
  2. Type MCP: Add Server and press Enter.

  3. For the server type, select HTTP.

  4. For the server URL, enter https://<gitlab.example.com>/api/v4/mcp.

    • Replace <gitlab.example.com> with:
      • On GitLab Self-Managed, your GitLab instance URL.
      • On GitLab.com, gitlab.com.
  5. For the server ID, enter GitLab.

  6. Save the configuration globally or in the vscode/mcp.json workspace.

    The OAuth authorization page should appear. Otherwise, open the Command Palette and search for MCP: List Servers to check the status or restart the server.

  7. In your browser, review and approve the authorization request.

You can now start a new chat and ask a question depending on the available tools.

You’re responsible for guarding against prompt injection when you use these tools. Exercise extreme caution or use MCP tools only on GitLab objects you trust.

Connect OpenAI Codex to the GitLab MCP server

OpenAI Codex uses HTTP transport for direct connection without additional dependencies. To configure the GitLab MCP server in OpenAI Codex:

  1. In your terminal, add the GitLab MCP server with the CLI:
    • Replace <gitlab.example.com> with:
      • On GitLab Self-Managed, your GitLab instance URL.
      • On GitLab.com, gitlab.com.
codex mcp add --url "https://<gitlab.example.com>/api/v4/mcp" GitLab
  1. Edit ~/.codex/config.toml and, in the [features] section, enable the rmcp_client feature flag.

    [features]
    "rmcp_client" = true
    
    [mcp_servers.GitLab]
    url = "https://<gitlab.example.com>/api/v4/mcp"
  2. Run the login flow and authenticate with the GitLab instance.

    codex mcp login GitLab
  3. In your browser, review and approve the authorization request.

You can now start a new chat and ask a question depending on the available tools.

You’re responsible for guarding against prompt injection when you use these tools. Exercise extreme caution or use MCP tools only on GitLab objects you trust.

Available tools

The GitLab MCP server provides the following tools.

get_mcp_server_version

Returns the current version of the GitLab MCP server.

Example:

What version of the GitLab MCP server am I connected to?

create_issue

Creates a new issue in a GitLab project.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
titlestringYesTitle of the issue.
descriptionstringNoDescription of the issue.
assignee_idsarray of integersNoArray of IDs of assigned users.
milestone_idintegerNoID of the milestone.
labelsarray of stringsNoArray of label names.
confidentialbooleanNoSets the issue to confidential. Default is false.
epic_idintegerNoID of the linked epic.

Example:

Create a new issue titled "Fix login bug" in project 123 with description
"Users cannot log in with special characters in password"

get_issue

Retrieves detailed information about a specific GitLab issue.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
issue_iidintegerYesInternal ID of the issue.

Example:

Get details for issue 42 in project 123

create_merge_request

Creates a merge request in a project.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
titlestringYesTitle of the merge request.
source_branchstringYesName of the source branch.
target_branchstringYesName of the target branch.
target_project_idintegerNoID of the target project.

Example:

Create a merge request in project gitlab-org/gitlab titled "Bug fix broken specs"
from branch "fix/specs-broken" into "master" and enable squash

get_merge_request

Retrieves detailed information about a specific GitLab merge request.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
merge_request_iidintegerYesInternal ID of the merge request.

Example:

Get details for merge request 15 in project gitlab-org/gitlab

get_merge_request_commits

Retrieves the list of commits in a specific merge request.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
merge_request_iidintegerYesInternal ID of the merge request.
per_pageintegerNoNumber of commits per page.
pageintegerNoCurrent page number.

Example:

Show me all commits in merge request 42 from project 123

get_merge_request_diffs

Retrieves the diffs for a specific merge request.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
merge_request_iidintegerYesInternal ID of the merge request.
per_pageintegerNoNumber of diffs per page.
pageintegerNoCurrent page number.

Example:

What files were changed in merge request 25 in the gitlab project?

get_merge_request_pipelines

Retrieves the pipelines for a specific merge request.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
merge_request_iidintegerYesInternal ID of the merge request.

Example:

Show me all pipelines for merge request 42 in project gitlab-org/gitlab

get_pipeline_jobs

Retrieves the jobs for a specific CI/CD pipeline.

ParameterTypeRequiredDescription
idstringYesID or URL-encoded path of the project.
pipeline_idintegerYesID of the pipeline.
per_pageintegerNoNumber of jobs per page.
pageintegerNoCurrent page number.

Example:

Show me all jobs in pipeline 12345 for project gitlab-org/gitlab

Searches for a term across the entire GitLab instance with the search API. This tool is available for global, group, and project search. Available scopes depend on the search type.

ParameterTypeRequiredDescription
scopestringYesSearch scope (for example, issues, merge_requests, or projects).
searchstringYesSearch term.
group_idstringNoID or URL-encoded path of the group you want to search.
project_idstringNoID or URL-encoded path of the project you want to search.
statestringNoState of search results (for issues and merge_requests).
confidentialbooleanNoFilters results by confidentiality (for issues). Default is false.
fieldsarray of stringsNoArray of fields you want to search (for issues and merge_requests).
order_bystringNoAttribute to order results by. Default is created_at for basic search and relevance for advanced search.
sortstringNoSort direction for results. Default is desc.
per_pageintegerNoNumber of results per page. Default is 20.
pageintegerNoCurrent page number. Default is 1.

Example:

Search issues for "flaky test" across GitLab
  • Offering: GitLab.com

Searches for relevant code snippets in a project.

This tool is available only for projects with GitLab Duo turned on. Project files must be indexed into vector embeddings.

If this tool is invoked for a project without vector embeddings, indexing is triggered ad-hoc and the agent uses a different tool. This tool then becomes available after a few minutes.

ParameterTypeRequiredDescription
semantic_querystringYesSearch query for the code.
project_idstringYesID or path of the project.
directory_pathstringNoPath of the directory (for example, app/services/).
knnintegerNoNumber of nearest neighbors used to find similar code snippets. Default is 64.
limitintegerNoMaximum number of results to return. Default is 20.

Example:

How are authorizations managed in this project?