GitLab MCP server
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- Status: Beta
- Introduced as an experiment in GitLab 18.3 with feature flags named
mcp_serverandoauth_dynamic_client_registration. Disabled by default. - Changed from experiment to beta in GitLab 18.6. Feature flags
mcp_serverandoauth_dynamic_client_registrationremoved. - Support for
2025-03-26and2025-06-18MCP protocol specifications added in GitLab 18.7. - Changed to a separate setting and moved from GitLab Premium to GitLab Free in GitLab 19.2.
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:
- Registers itself as an OAuth application.
- Requests authorization to access your GitLab data.
- Receives an access token for secure API access.
For a click-through demo, see GitLab Duo Agent Platform - GitLab MCP server.
Prerequisites
- Set GitLab Duo availability to Always on or On by default:
- On GitLab.com, for the top-level group.
- On GitLab Self-Managed and GitLab Dedicated, for the instance.
- Turn on beta and experimental features:
- On GitLab.com, for the top-level group.
- On GitLab Self-Managed and GitLab Dedicated, for the instance.
- Allow access to the MCP server:
- On GitLab.com, for the top-level group.
- On GitLab Self-Managed and GitLab Dedicated, for the instance.
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.
HTTP transport (recommended)
- Introduced in GitLab 18.6.
- Tool prefixing added in GitLab 18.11.
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"
}
}
}You can add a prefix to tool names by configuring an
X-Gitlab-Mcp-Server-Tool-Name-Prefix HTTP header.
Prefixing can help you avoid tool name conflicts with other MCP servers
or with multiple GitLab instances in your configuration.
The prefix is truncated to the first 32 characters if it exceeds this limit.
{
"mcpServers": {
"GitLab": {
"type": "http",
"url": "https://<gitlab.example.com>/api/v4/mcp",
"headers": {
"X-Gitlab-Mcp-Server-Tool-Name-Prefix": "gitlab_"
}
}
}
}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, ifnpxis installed locally instead of globally, provide the full path tonpx. - 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:
In Cursor, go to Settings > Cursor Settings > Tools & MCP.
Under Installed MCP Servers, select New MCP Server.
Add this definition to the
mcpServerskey in the openedmcp.jsonfile:- 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" } } }- Replace
Save the file, and wait for your browser to open the OAuth authorization page.
If this does not happen, close and restart Cursor.
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:
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- Replace
Start Claude Code:
claudeAuthenticate 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.
- In the chat, type
Optional. To verify the connection, type
/mcpagain. 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.
- Have Node.js available globally in the
PATHenvironment variable (which -a node).
To configure the GitLab MCP server in Claude Desktop:
Open Claude Desktop.
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.jsonfile.
Add this entry for the GitLab MCP server, editing as needed:
- For the
"command":parameter, ifnpxis installed locally instead of globally, provide the full path tonpx. - 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" ] } } }- For the
Save the configuration and restart Claude Desktop.
On first connect, Claude Desktop opens a browser window for OAuth. Review and approve the request.
Go to Settings > Developer and verify the new GitLab MCP configuration.
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:
Edit
~/.gemini/settings.jsonand 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" } } }- Replace
In Gemini Code Assist or Gemini CLI, run the
/mcp auth GitLabcommand.The OAuth authorization page should appear. Otherwise, restart Gemini Code Assist or Gemini CLI.
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:
In VS Code, open the Command Palette:
- On macOS, press Command+Shift+P.
- On Windows or Linux, press Control+Shift+P.
Type
MCP: Add Serverand press Enter.For the server type, select HTTP.
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.
- Replace
For the server ID, enter
GitLab.Save the configuration globally or in the
vscode/mcp.jsonworkspace.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.
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 Kiro IDE and CLI to the GitLab MCP server
Kiro IDE and CLI use HTTP transport for direct connection without additional dependencies. To configure the GitLab MCP server in Kiro IDE or CLI:
Edit
~/.kiro/settings/mcp.jsonand 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": { "type": "http", "url": "https://<gitlab.example.com>/api/v4/mcp" } } }- Replace
Save the configuration.
The OAuth authorization page should appear. Otherwise, open Kiro CLI and run the
/mcpcommand.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:
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- Replace
Edit
~/.codex/config.tomland, in the[features]section, enable thermcp_clientfeature flag.[features] "rmcp_client" = true [mcp_servers.GitLab] url = "https://<gitlab.example.com>/api/v4/mcp"Run the login flow and authenticate with the GitLab instance.
codex mcp login GitLabIn 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 Zed to the GitLab MCP server
Prerequisites:
- Install Node.js version 20 or later.
- Have Node.js available globally in the
PATHenvironment variable (which -a node).
To configure the GitLab MCP server in Zed:
In Zed, open the Command Palette:
- On macOS, press Command+Shift+P.
- On Windows or Linux, press Control+Shift+P.
Type
agent: open settingsand press Enter.In the Model Context Protocol (MCP) Servers section, select Add Server.
For the server URL in
args, usehttps://<gitlab.example.com>/api/v4/mcp.- Replace
<gitlab.example.com>with:- On GitLab Self-Managed, your GitLab instance URL.
- On GitLab.com,
gitlab.com.
{ /// The name of your MCP server "GitLab": { /// The command which runs the MCP server "command": "npx", /// The arguments to pass to the MCP server "args": ["-y","mcp-remote@latest","https://<gitlab.example.com>/api/v4/mcp"], /// The environment variables to set "env": {} } }- Replace
Save the configuration.
The OAuth authorization page should appear. If not, turn the GitLab toggle off and on again.
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.
Reuse a single OAuth application
- Offering: GitLab Self-Managed, GitLab Dedicated
When an MCP client connects to the GitLab MCP server, it uses OAuth 2.0 Dynamic Client Registration (DCR) to create a new OAuth application on your GitLab instance. In environments with many users or frequent reconnections, this can result in a large number of OAuth applications on the instance.
To avoid a large number of OAuth applications, create a single, shared OAuth application and give its client ID to users.
When users configure their MCP client with this client ID, all connections reuse the same OAuth application instead of creating new ones.
When a user authenticates with the shared clientId, GitLab reuses the same OAuth application
for every subsequent authentication from any user with the same configuration.
User authorize with OAuth and receive their own access token.
The shared application is the OAuth client identity, not a shared credential.
Prerequisites:
- You must be an administrator.
- An MCP client that supports the following:
- Pre-configured OAuth credentials
- The
clientIdfield in its configuration
- Use the REST API to create a single OAuth application
for the instance. Set
mcpas the scope andconfidential: false - Give the
application_idin the response to your users. This is theclientIDthat users configure in the MCP client. The configuration key varies by client, but is typically namedclientIdorclient_idin the OAuth configuration of the GitLab MCP server. This is typically in anmcp.jsonfile.
The redirect URI registered on the OAuth application must exactly match the redirect URI your MCP client sends during the OAuth flow. Check your client’s documentation for the redirect URI it uses. A single shared OAuth application cannot serve MCP clients that use different redirect URIs. If your users use MCP clients with different redirect URIs, create a separate shared OAuth application for each client type.
Security considerations
Users who authenticate with the client ID must still complete the OAuth authorization with their own GitLab credentials. They can access only the data they are permitted to.
GitLab does not verify which MCP client application presents the clientId.
If you create an OAuth application for a specific MCP client,
any other MCP client that supports pre-registration could use the same clientId to authenticate.
The clientId controls which OAuth application is used, not which client software is allowed.
Pre-registered applications created with the REST API do not enforce Proof Key for Code Exchange (PKCE). PKCE defends against authorization code interception for public clients.
To enforce PKCE, verify that your MCP client sends code_challenge and code_challenge_method parameters during the OAuth flow.
GitLab accepts PKCE parameters for pre-registered applications, but does not require them.