doc/user/gitlab_duo/model_context_protocol/mcp_server.md
{{< details >}}
{{< /details >}}
{{< history >}}
mcp_server and oauth_dynamic_client_registration. Disabled by default.mcp_server and oauth_dynamic_client_registration removed.2025-03-26 and 2025-06-18 MCP protocol specifications added in GitLab 18.7.{{< /history >}}
[!warning] 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:
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:
For a click-through demo, see GitLab Duo Agent Platform - GitLab MCP server.
<!-- Demo published on 2025-09-11 -->The GitLab MCP server supports two transport types:
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.
{{< history >}}
{{< /history >}}
To configure the GitLab MCP server by using HTTP transport, use this format:
<gitlab.example.com> with:
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_"
}
}
}
}
mcp-remotePrerequisites:
To configure the GitLab MCP server by using stdio transport, use this format:
"command": parameter, if npx is installed locally instead of globally, provide the full path to npx.<gitlab.example.com> with:
gitlab.com.{
"mcpServers": {
"GitLab": {
"command": "npx",
"args": [
"mcp-remote",
"https://<gitlab.example.com>/api/v4/mcp"
]
}
}
}
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 mcpServers key in the opened mcp.json file:
<gitlab.example.com> with:
gitlab.com.{
"mcpServers": {
"GitLab": {
"type": "http",
"url": "https://<gitlab.example.com>/api/v4/mcp"
}
}
}
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.
[!warning] 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.
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:
<gitlab.example.com> with:
gitlab.com.claude mcp add --transport http GitLab https://<gitlab.example.com>/api/v4/mcp
Start Claude Code:
claude
Authenticate with the GitLab MCP server:
/mcp.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.
[!warning] 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.
Prerequisites:
PATH environment 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:
~/Library/Application Support/Claude/claude_desktop_config.json file.Add this entry for the GitLab MCP server, editing as needed:
"command": parameter, if npx is installed locally instead of globally, provide the full path to npx.<gitlab.example.com> with:
GitLab.com.{
"mcpServers": {
"GitLab": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://<gitlab.example.com>/api/v4/mcp"
]
}
}
}
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.
[!warning] 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.
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.json and add the GitLab MCP server.
<gitlab.example.com> with:
gitlab.com.{
"mcpServers": {
"GitLab": {
"httpUrl": "https://<gitlab.example.com>/api/v4/mcp"
}
}
}
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.
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.
[!warning] 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.
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:
Type MCP: Add Server and press <kbd>Enter</kbd>.
For the server type, select HTTP.
For the server URL, enter https://<gitlab.example.com>/api/v4/mcp.
<gitlab.example.com> with:
gitlab.com.For the server ID, enter GitLab.
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.
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.
[!warning] 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.
Prerequisites:
PATH environment variable (which -a node).To configure the GitLab MCP server in Continue in VS Code:
In VS Code, in the Activity Bar, select the Continue extension.
Open the settings and select Tools.
Next to MCP Servers, add a new server.
Edit the configuration file .continue/mcpServers/new-mcp-server.yaml:
<gitlab.example.com> with:
gitlab.com.name: GitLab MCP server
version: 0.0.1
schema: v1
mcpServers:
- name: GitLab MCP server
type: stdio
command: npx
args:
- mcp-remote
- https://<gitlab.example.com>/api/v4/mcp
Save the configuration.
The OAuth authorization page should appear.
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.
[!warning] 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.
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.json and add the GitLab MCP server.
<gitlab.example.com> with:
gitlab.com.{
"mcpServers": {
"GitLab": {
"type": "http",
"url": "https://<gitlab.example.com>/api/v4/mcp"
}
}
}
Save the configuration.
The OAuth authorization page should appear.
Otherwise, open Kiro CLI and run the /mcp command.
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.
[!warning] 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.
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:
<gitlab.example.com> with:
gitlab.com.codex mcp add --url "https://<gitlab.example.com>/api/v4/mcp" GitLab
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"
Run the login flow and authenticate with the GitLab instance.
codex mcp login GitLab
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.
[!warning] 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.
Prerequisites:
PATH environment variable (which -a node).To configure the GitLab MCP server in Zed:
In Zed, open the Command Palette:
Type agent: open settings and press <kbd>Enter</kbd>.
In the Model Context Protocol (MCP) Servers section, select Add Server.
For the server URL in args, use https://<gitlab.example.com>/api/v4/mcp.
<gitlab.example.com> with:
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": {}
}
}
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.
[!warning] 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.