Skip to main content

AI Agents

JetLab — GitLab exposes its merge request tools through a Model Context Protocol (MCP) server, so an AI coding agent can browse merge requests, read diffs, and comment on the changes without leaving your IDE. Any MCP-capable agent works; the examples below use Claude Code.

info

AI agent support is experimental and still evolving. Your feedback is very welcome — reach us through the support portal or by email.

When the agent comments on a merge request, it doesn't publish the comment right away. Each comment is created as a pending comment — part of a review that is stored on GitLab but visible only to you until you publish it. You review the pending comments in the IDE and publish them all at once with Finish review, or discard them. See Reviews for how the pending-review workflow works.

Requirements

  • A JetBrains IDE (2025.2 or later) with the bundled MCP Server plugin, which is enabled by default.
  • A configured GitLab repository (see Managing Repositories). The tools are available only while at least one repository is configured.
  • For workflows where the agent checks out a branch, the repository must be associated with a local VCS root.

Connecting an Agent

  1. In the IDE, open Settings | Tools | MCP Server and click Enable MCP Server.
  2. In the Clients Auto-Configuration section, click Auto-Configure next to your agent. Claude Code, Claude Desktop, Cursor, VS Code, and others are supported. For a client that isn't listed, use Copy SSE Config or Copy Stdio Config from the Manual Client Configuration section instead.
  3. Start your agent — for example, run Claude Code in the IDE's built-in terminal so it operates inside your project. The JetLab — GitLab tools become available, prefixed with gitlab_.

Available Tools

You don't call these directly — describe what you want in plain language and the agent picks the right tools.

ToolPurpose
gitlab_list_my_merge_requestsList open merge requests where you are the author, assignee, or reviewer.
gitlab_get_merge_requestGet a merge request's summary, changed files, discussions, and commits.
gitlab_get_file_diffGet the diff of a single changed file.
gitlab_add_commentComment on the changes or reply to a discussion. Created as a pending review comment.

Pointing the Agent at a Merge Request

The agent needs to know which merge request to work on. The easiest way is to paste its link into your prompt:

  • Use Copy Link — from the merge request's toolbar or its right-click menu in the GitLab Merge Requests tool window — and paste the URL into your prompt.
  • Or, if you have the merge request's branch checked out, just refer to "the current merge request" — the agent resolves it from the checked-out branch.

Reviewing a New Merge Request

Paste the merge request link and ask the agent to review it. The branch doesn't have to be checked out — the diff is read from GitLab — though checking it out first produces a more thorough review (see the tip below).

Review this GitLab merge request and leave inline comments on it for any bugs,
correctness problems, or risky changes you find:
https://gitlab.com/group/project/-/merge_requests/123

The agent fetches the changed files and existing discussions, reads each diff, and adds inline comments. Open the merge request in the GitLab Merge Requests tool window to see the pending comments in the Discussions tab, then publish them all at once with Finish review or discard them.

tip

For a more thorough review, check out the merge request's branch first with Checkout Branch, then tell the agent to use it — for example, add "the branch is checked out — use the whole project for context" to your prompt. The agent can then read the full files and use IDE context such as inspections and find-usages, instead of the diff alone. Checkout requires the repository to be associated with a local VCS root.

Reviewing Part of a Merge Request

By default the agent reviews the whole merge request. You can also scope the review to part of it — for example, to re-review only what the author pushed since your last pass. The tools don't track what you've already reviewed, so tell the agent what to look at. If you don't know the exact commit or version, ask the agent to list the merge request's commits or versions first.

By commit — review a single commit's changes:

Review the changes in commit <hash> of this GitLab merge request and leave inline
comments on any issues:
https://gitlab.com/group/project/-/merge_requests/123

By version — GitLab records each push to the merge request as a numbered version. Review what changed between versions; omit the starting version to compare from the target branch, or the ending version to compare up to the latest:

Review what changed in this GitLab merge request since version 2 and leave inline
comments on any issues:
https://gitlab.com/group/project/-/merge_requests/123

Addressing Review Comments as the Author

When you're the author, the agent can apply the requested changes locally while you stay in control of what gets committed and what gets sent back to the reviewers.

1. Let the agent make the changes. If the merge request's branch isn't checked out yet, check it out first with Checkout Branch. Then the agent reads the discussions and edits the working tree — without committing.

This is my GitLab merge request:
https://gitlab.com/group/project/-/merge_requests/123
Read the open review comments and update the code to address them. Don't commit
or push — I'll review and commit the changes myself.

2. Review and commit in the IDE. Inspect the agent's edits, then commit and push from the IDE as usual. This keeps you in control of the code that lands.

3. Let the agent reply to the discussions. After your push, ask the agent to respond to each thread it addressed.

I've committed and pushed the changes. Post a reply on the GitLab merge request to
each review comment you addressed, noting what changed.

The replies are added as pending comments on the existing discussions. Review them in the Discussions tab and publish them all at once with Finish review.

Disabling the Tools

To turn the JetLab — GitLab tools off for AI agents, open Settings | Tools | MCP Server | Exposed Tools and disable the gitlab_ tools. To turn off all MCP access, clear Enable MCP Server on the Settings | Tools | MCP Server page.

Troubleshooting

If the gitlab_ tools don't appear in your agent:

  • Confirm Enable MCP Server is on in Settings | Tools | MCP Server, and re-run Auto-Configure for your client.
  • Check that the gitlab_ tools are enabled under Settings | Tools | MCP Server | Exposed Tools.
  • Confirm a repository is configured for JetLab — GitLab — the tools are available only when at least one repository is set up.