Set up GitLab MCP Server

Start Set up GitLab MCP Server – configure OAuth, set minimal permissions, and understand prompt injection risks.

Published on 18.09.2026

The GitLab MCP Server connects AI coding agents like Claude Code, Cursor, or GitHub Copilot directly to a GitLab instance. After setup, the agent can read issues, create merge requests, commit code, and retrieve pipeline results — directly from the chat. This guide covers setup via HTTP transport (recommended) and provides security recommendations for production use.

Check prerequisites

Before setup, make sure you have a GitLab account and that MCP server access is allowed on the GitLab instance. On GitLab.com, access may be restricted at the group level; on self-managed instances, the administrator controls access via instance settings. For the recommended HTTP transport, no additional software is needed. For stdio transport via mcp-remote, Node.js version 20 or higher is required.

Configure the client

Claude Code: A single command sets up the server:

claude mcp add --transport http GitLab https://gitlab.com/api/v4/mcp

For a self-managed instance, adjust the URL accordingly, e.g. https://gitlab.example.com/api/v4/mcp.

Cursor: Under Settings > Cursor Settings > Tools & MCP, add a new MCP server and enter the URL https://gitlab.com/api/v4/mcp with type http.

GitHub Copilot in VS Code: Open the Command Palette (Ctrl+Shift+P), select MCP: Add Server, choose HTTP as the server type, and enter the URL https://gitlab.com/api/v4/mcp.

Claude Desktop and clients without HTTP transport: Add the following block to the MCP configuration file (Node.js ≥20 required):

{
  "mcpServers": {
    "GitLab": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://gitlab.com/api/v4/mcp"]
    }
  }
}

Complete the OAuth login

On first connection, a browser window opens automatically with a GitLab OAuth authorization page. Review the requested permissions and confirm. The client saves the access token for subsequent sessions. Use /mcp (in Claude Code) or the respective client command to check the connection status at any time.

Minimize permissions

The server always acts with the full rights of the authenticated GitLab user. For automated or agentic workflows, a dedicated GitLab service account with access limited to only the actually required projects is recommended. In GitLab, project roles (Guest, Reporter, Developer, Maintainer, Owner) limit the action scope. For pure analysis workflows (reading issues, checking MR status), the Reporter or Developer role without push rights is sufficient.

Be aware of prompt injection

According to the official GitLab documentation, content in issues, merge request descriptions, or code files can contain instructions that cause the agent to take unintended actions. MCP tools should therefore only be activated on GitLab projects and objects you trust. Extra caution is warranted when working with public repositories or forks from unknown sources.

Published on 18.09.2026

Categories

Frequently asked questions

Does the server work with a self-managed GitLab instance?

Yes. According to the provider, the server supports GitLab.com, self-managed, and GitLab Dedicated. Only the own instance URL needs to be entered instead of gitlab.com in the client configuration.

Is a paid GitLab plan required?

No. According to the provider, the MCP server is available for all tiers (Free, Premium, Ultimate). Certain GitLab features accessed by the tools may require higher plans.

How do I limit agent access?

A dedicated service account with roles limited to the required projects (Reporter, Developer) minimizes risk. On GitLab.com, MCP access can be restricted at the group level; on self-managed instances, instance configuration controls access.

Is there a public repository?

No. The GitLab MCP Server is integrated into the main GitLab application (endpoint /api/v4/mcp) and is not published as a separate package.