Skip to content

Connect Claude Code to the GitLab MCP server

The GitLab MCP server lets Claude Code read and work with issues, merge requests, pipelines and repository contents as you. Connecting agents to GitLab with the MCP server explains what it can reach and why we use it.

This how-to covers adding the server to Claude Code, signing in, and signing in again when needed.

Prerequisites

Add the server

Run this command in a terminal:

claude mcp add -s user --transport http GitLab https://gitlab.developers.cam.ac.uk/api/v4/mcp

-s user adds the server to your user configuration, so it is available in every project. The name GitLab is the one Claude Code uses in tool names such as mcp__GitLab__get_merge_request, and in any permission rules you write for them.

Sign in from the browser

  1. Start Claude Code by running claude.
  2. Type /mcp and press Enter. GitLab is listed as needing authentication.
  3. Select GitLab, then choose Authenticate. Claude Code opens GitLab in your browser.
  4. If GitLab asks you to sign in, sign in with your University account.
  5. Click Authorize to let Claude Code access GitLab on your behalf.
  6. Return to the terminal. /mcp now shows GitLab as connected.

To check it works, ask Claude Code to list your open merge requests.

Re-authenticate

Claude Code refreshes its GitLab token automatically, so you rarely need to do this. Sign in again if Claude Code shows a notice asking you to, if /mcp shows GitLab as needing authentication, or after you have revoked Claude Code's access in GitLab.

  1. In Claude Code, type /mcp and press Enter.
  2. Select GitLab, then choose Re-authenticate.
  3. Complete the browser sign-in as before.

If re-authenticating doesn't help, choose Clear authentication to remove the stored token, then Authenticate to sign in from scratch.

To withdraw Claude Code's access from the GitLab side, open your authorized applications in GitLab user settings and revoke the Claude Code entry. You will then need to authenticate again before Claude Code can use the server.

Summary

In this how-to, you learned how to connect Claude Code to the GitLab MCP server and sign it in again when needed.

Next steps