GitLab MCP server merge request tools
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
To provide feedback on this feature, leave a comment on issue 630189.
These tools are part of the merge_requests toolset.
Use them to create, update, read, list, review, and accept merge requests, and apply suggestions.
For a list of all tools, see GitLab MCP server tools.
save_merge_request
Creates or updates a merge request in a GitLab project.
The presence of merge_request_iid selects the operation: omit it to create a merge request, or provide it to update an existing one.
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | Yes | ID or full path of the project. |
merge_request_iid | integer | No | Internal ID of the merge request. Provide to update an existing merge request; omit to create one. |
title | string | No | Title of the merge request. Required when creating. |
source_branch | string | No | Name of the source branch. Required when creating. |
target_branch | string | No | Name of the target branch. Required when creating. |
target_project_id | integer | No | ID of the target project. Applies when creating. |
description | string | No | Description of the merge request. |
labels | array of strings | No | Label names. Replaces all existing labels. Pass an empty array to remove all labels. |
add_labels | array of strings | No | Label names to add. Applies when updating. |
remove_labels | array of strings | No | Label names to remove. Applies when updating. |
assignees | array of strings | No | Usernames to assign. Alternative to assignee_ids; provide one. Pass an empty array to remove all assignees. |
assignee_ids | array of integers | No | User IDs to assign. Alternative to assignees; provide one. Pass an empty array to remove all assignees. |
reviewers | array of strings | No | Usernames to request review from. Alternative to reviewer_ids; provide one. Pass an empty array to remove all reviewers. |
reviewer_ids | array of integers | No | User IDs to request review from. Alternative to reviewers; provide one. Pass an empty array to remove all reviewers. |
milestone_id | integer | No | ID of the milestone. |
milestone | string | No | Title of a project or ancestor-group milestone to assign. Mutually exclusive with milestone_id. |
remove_source_branch | boolean | No | Remove the source branch when the merge request is merged. |
squash | boolean | No | Squash commits into a single commit when merging. |
state_event | string | No | State transition to perform. One of close or reopen. Applies when updating. |
discussion_locked | boolean | No | Lock the merge request discussion. Applies when updating. |
allow_collaboration | boolean | No | Allow commits from members who can merge to the target branch. Applies when updating. |
Examples:
Create a merge request in project gitlab-org/gitlab titled "Bug fix broken specs"
from branch "fix/specs-broken" into "master" and enable squashUpdate merge request 42 in project gitlab-org/gitlab to add the "bug" label and close itget_merge_request
Retrieves a merge request and, optionally, its diffs, commits, notes, pipelines, discussions, approvals, or
conflicts.
The base response includes reviewers, labels, diffHeadSha, and detailedMergeStatus.
Labels retain the raw GraphQL connection shape, with nodes containing each label’s id
and title. In contrast, list_merge_requests returns labels as a flat list of titles.
Additional associated data is returned when you request it with the include parameter.
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | No | GitLab URL of the merge request. Provide this, or project_id and merge_request_iid. |
project_id | string | No | ID or full path of the project. Required if url is missing. |
merge_request_iid | integer | No | Internal ID of the merge request. Required if url is missing. |
include | array | No | Associated facets to return with the merge request. Any of diffs, commits, notes, pipelines, discussions, approvals, or conflicts. You can request several facets in one call. |
detail | string | No | Level of diff detail. One of none for summary counts only, stats for per-file additions and deletions, or full_patch for per-file patch text plus the per-file stats. Default is stats. Applies only when include contains diffs. Cannot be full_patch when include has other facets. |
diffs_after | string | No | Cursor for forward pagination of files. Applies only when include contains diffs and detail is full_patch. |
diffs_first | integer | No | Number of files to return after the cursor, up to 100. Applies only when include contains diffs and detail is full_patch. |
notes_after | string | No | Cursor for forward pagination of notes. Applies only when include contains notes. |
notes_first | integer | No | Number of notes to return after the cursor, up to 100. Applies only when include contains notes. |
notes_before | string | No | Cursor for backward pagination of notes. Applies only when include contains notes. |
notes_last | integer | No | Number of notes to return before the cursor, up to 100. Applies only when include contains notes. |
commits_after | string | No | Cursor for forward pagination of commits. Applies only when include contains commits. |
commits_first | integer | No | Number of commits to return after the cursor, up to 100. Applies only when include contains commits. |
pipelines_after | string | No | Cursor for forward pagination of pipelines. Applies only when include contains pipelines. |
pipelines_first | integer | No | Number of pipelines to return after the cursor, up to 100. Applies only when include contains pipelines. |
The diffs facet returns change statistics by default: overall totals and per-file additions and
deletions. To get patch text, set detail to full_patch.
When diffsOverflow is true, the merge request diff exceeds the diff size limits and some changed
files have no patch text.
With detail: "full_patch", page through the diffs with diffs_after set to diffs.pageInfo.endCursor
until diffs.pageInfo.hasNextPage is false.
The response’s system_instruction explains how to read files that appear in stats but in no
full_patch page.
Deleted files cannot be read at diffHeadSha.
The commits and pipelines facets return up to 100 entries per call. Each response carries
pageInfo.hasNextPage and pageInfo.endCursor. Pass that cursor back as commits_after or
pipelines_after to read the next page.
The notes facet also pages backward with notes_last and notes_before. To read the newest
notes, pass notes_last without notes_first or notes_after. If you pass notes_first, the
call pages forward and ignores notes_last and notes_before. If you pass notes_last without
notes_first, the call pages backward and ignores notes_after. If you pass only cursors,
notes_after takes precedence over notes_before.
Each note returns its position (the file and line of a diff comment) and
its discussion (the thread it belongs to, and whether the thread is resolved). The response also
includes resolvedDiscussionsCount and resolvableDiscussionsCount.
In the notes and discussions facets, each note also lists up to 20 of its suggestions.
Each suggestion has a numeric id, toContent (the suggested text), and applied (whether the
suggestion is applied). Pass the id to
apply_suggestion to apply that suggestion.
The conflicts facet returns raw conflict file content, including Git conflict markers. It is
available only when the merge request cannot be merged and you can push to the source branch, and
is null until mergeability has been checked. Read the base conflicts field to determine the state.
Example:
Get merge request 15 in project gitlab-org/gitlab with its commitslist_merge_requests
Lists or searches merge requests in a GitLab project or group, returning compact merge request metadata,
including reviewers, labels, draft status, and creation and update timestamps.
Group scope always includes merge requests from every project in the group and its subgroups, but excludes
merge requests from archived projects.
A group result also includes the owning project path of each merge request, for use with get_merge_request.
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | No | GitLab URL of the project or group. Provide exactly one of url, project_id, or group_id. |
project_id | string | No | ID or full path of the project. Provide exactly one of url, project_id, or group_id. |
group_id | string | No | ID or full path of the group. Provide exactly one of url, project_id, or group_id. |
author_username | string | No | Filter by the username of the merge request author. |
assignee_username | string | No | Filter by the username of an assignee. |
reviewer_username | string | No | Filter by the username of a reviewer. |
reviewer_wildcard_id | string | No | Filter by reviewer presence: NONE returns merge requests with no reviewer; ANY returns merge requests with at least one reviewer. Cannot be combined with reviewer_username or scope: review_requested. |
state | string | No | Filter by state. One of opened, closed, merged, locked, or all. Omit to include any state. |
scope | string | No | Filter relative to the authenticated user. One of created_by_me, assigned_to_me, or review_requested. An explicit username wins for that field. |
milestone | string | No | Filter by the title of the milestone. |
labels | string | No | Comma-separated list of label names. Only merge requests with all of these labels are returned. |
search | string | No | Search query matched against merge request title and description. |
after | string | No | Cursor for forward pagination. |
first | integer | No | Number of merge requests to return for forward pagination. Default is 20, maximum is 100. |
To retrieve a single merge request in full detail, use get_merge_request. To get its commits, use
get_merge_request with include: ["commits"]. For diffs or notes, use include: ["diffs"]
or include: ["notes"]. To get patch text, also set detail to full_patch. For full-text search
across resource types, use search.
Example:
List my open merge requests in gitlab-org/gitlabget_merge_request_commits
Superseded by get_merge_request with include: ["commits"]. This tool no
longer appears in tools/list but remains callable while callers migrate.
Retrieves the list of commits in a specific GitLab merge request.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | ID or full path of the project. |
merge_request_iid | integer | Yes | Internal ID of the merge request. |
per_page | integer | No | Number of commits per page. |
page | integer | No | Current page number. |
Example:
Show me all commits in merge request 42 from project 123get_merge_request_diffs
Superseded by get_merge_request with include: ["diffs"]. For raw patch text,
also pass detail: full_patch. This tool no longer appears in tools/list but remains callable
while callers migrate.
Retrieves the diffs for a specific GitLab merge request.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | ID or full path of the project. |
merge_request_iid | integer | Yes | Internal ID of the merge request. |
per_page | integer | No | Number of diffs per page. |
page | integer | No | Current page number. |
Example:
What files were changed in merge request 25 in the gitlab project?get_merge_request_pipelines
Superseded by get_merge_request with include: ["pipelines"]. This tool no
longer appears in tools/list but remains callable while callers migrate.
Retrieves the pipelines for a specific GitLab merge request.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | ID or full path of the project. |
merge_request_iid | integer | Yes | Internal ID of the merge request. |
Example:
Show me all pipelines for merge request 42 in project gitlab-org/gitlabget_merge_request_conflicts
Superseded by get_merge_request with include: ["conflicts"], which
returns the same conflicts as structured conflictFiles entries with separate ourPath and
theirPath fields, instead of the plain text below. This tool no longer appears in
tools/list but remains callable while callers migrate.
Retrieves the merge conflict content for a merge request that cannot be merged.
Returns the raw Git conflict markers (<<<<<<<, =======, and >>>>>>>) exactly as they
appear in the conflicted files. Each file’s content is grouped under a # File: heading.
For renamed files, the heading shows the path in each branch.
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | Yes | ID or full path of the project (for example, gitlab-org/gitlab). |
merge_request_iid | integer | Yes | Internal ID of the merge request. |
You must have permission to push to the source branch of the merge request. The tool returns an error when the merge request has no conflicts, when its mergeability has not been checked yet, or when a branch or diff ref is missing.
Example:
Show the conflicts for merge request 42 in project gitlab-org/gitlabget_merge_request_notes
Superseded by get_merge_request with include: ["notes"]. This tool no
longer appears in tools/list but remains callable while callers migrate.
Retrieves the notes (comments and system notes) for a specific GitLab merge request.
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | No | URL of the GitLab merge request. Required if project_id and merge_request_iid are missing. |
project_id | string | No | ID or full path of the project. Required if url is missing. |
merge_request_iid | integer | No | Internal ID of the merge request. Required if url is missing. |
after | string | No | Cursor for forward pagination. |
before | string | No | Cursor for backward pagination. |
first | integer | No | Number of notes to return for forward pagination. |
last | integer | No | Number of notes to return for backward pagination. |
Each returned note includes its discussion ID, so related notes can be grouped into threads.
Each note also lists up to 20 of its suggestions. Each suggestion has a numeric id, toContent
(the suggested text), and applied (whether the suggestion is applied).
Example:
Show me all comments on merge request 5 in project gitlab-org/gitlabsave_merge_request_review
Writes merge request review artifacts as the authenticated user. Each call performs
exactly one operation, selected with the method parameter:
| Method | Action |
|---|---|
create_note | Adds a top-level comment. |
reply_discussion | Replies in an existing discussion. |
create_diff_note | Comments on a specific diff line. |
resolve_discussion | Resolves or unresolves a discussion. |
update_note | Replaces the text of a note on the merge request. You must be the note author or have at least the Maintainer role. |
submit_review | Posts multiple diff comments and an optional summary in one call. |
post_duo_review | Asks GitLab Duo to review the merge request. Requires GitLab Duo Code Review. |
approve | Approves the merge request. Already-approved calls succeed with status already_approved. |
unapprove | Removes your approval. Calls without a prior approval succeed with status not_approved. |
Responses from post_duo_review, approve, and unapprove include the merge request’s
current diff_head_sha, so you can tell whether a standing approval or review still covers
the latest commits.
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | No | URL of the GitLab merge request, or a comment link ending in #note_<id>. Required if project_id and merge_request_iid are missing. |
project_id | string | No | ID or path of the project. Required if url is missing. |
merge_request_iid | integer | No | Internal ID of the merge request. Required if url is missing. |
method | string | Yes | The operation to perform. Parameters that belong to a different method are rejected. |
body | string | No | Note text. Required for create_note, reply_discussion, create_diff_note, and update_note. Lines cannot start with / to avoid triggering quick actions (for example, /merge). |
discussion_id | string | No | Discussion to act on. Required for reply_discussion and resolve_discussion. Accepts a global ID or a bare discussion ID. |
note_id | integer | No | Note to act on. Required for update_note unless url includes the comment anchor (#note_<id>). Accepts the integer note ID returned by create_note. To edit a note found with get_merge_request and include: ["notes"], pass its webUrl as url. The note must belong to the specified merge request. Comments on the merge request’s commits are not supported. |
internal | boolean | No | For create_note, marks the note as internal. |
resolved | boolean | No | For resolve_discussion: true resolves, false unresolves. Required for that method. |
old_path | string | No | For create_diff_note, the file path before the change. Provide old_path or new_path, or both. |
new_path | string | No | For create_diff_note, the file path after the change. |
old_line | integer | No | For create_diff_note, the line number in the old version. Provide old_line or new_line, or both. |
new_line | integer | No | For create_diff_note, the line number in the new version. |
comments | array | No | For submit_review, 1-20 diff comments. Each entry takes file and body (required), and old_line, new_line, and suggestion (optional). Required for that method. file is the post-change path; for renamed files, use create_diff_note instead. |
verdict | string | No | For submit_review, an overall verdict prefixed to the summary note. |
summary | string | No | For submit_review, a summary note posted after the diff comments. |
summary_internal | boolean | No | For submit_review, marks the summary note as internal. |
sha | string | No | For approve, a head SHA guard. When given and it no longer matches the merge request head, or the diff changed since a version with that head, the approval is refused. Pass the full 40-character diffHeadSha returned by get_merge_request. |
Example:
Review merge request 42 in project gitlab-org/gitlab and leave your findings as diff comments with a summaryaccept_merge_request
Merges a merge request, or schedules it to merge automatically. Without strategy, the merge
starts immediately and completes asynchronously. With strategy, auto-merge is armed and the
merge request merges once its checks pass. To approve a merge request instead, use the
save_merge_request_review tool.
Calls against a merge request that is already merged succeed with status already_merged,
and calls with a strategy against a merge request that is already scheduled succeed with
status already_scheduled.
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | No | GitLab URL of the merge request. Provide this, or project_id and merge_request_iid. |
project_id | string | No | ID or path of the project. Required if url is missing. |
merge_request_iid | integer | No | Internal ID of the merge request. Required if url is missing. |
sha | string | Yes | Head SHA guard. When it no longer matches the merge request head, the merge is refused. Pass the diffHeadSha returned by get_merge_request. |
strategy | string | No | Auto-merge strategy, for example merge_when_checks_pass. When given, arms auto-merge instead of merging immediately. |
squash | boolean | No | Squash the commits into a single commit on merge. |
commit_message | string | No | Custom merge commit message. |
squash_commit_message | string | No | Custom squash commit message. Applies when squash is true. |
should_remove_source_branch | boolean | No | Remove the source branch after merging. |
Example:
Merge merge request 42 in project gitlab-org/gitlab once its checks pass, and remove the source branchapply_suggestion
Prerequisites:
- You must have permission to push to the source branch of the merge request.
Applies a code review suggestion as a commit on the source branch of its merge request.
To get the ID of a suggestion, use get_merge_request with include set to notes or discussions.
Each note lists up to 20 of its suggestions with their IDs.
The response contains the suggestion with the following fields:
idfrom_lineto_lineappliableappliedfrom_contentto_content
The call fails with one of the following statuses:
404when the suggestion doesn’t exist.403when you don’t have permission to apply the suggestion, or when the suggestion is on a file that the project excludes from GitLab Duo context.400when the suggestion can’t be applied, for example because the line changed in a more recent version of the merge request.
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | ID of the suggestion. |
commit_message | string | No | Custom commit message. Replaces the generated message or the project’s commit message for applied suggestions. |
Example:
Apply suggestion 123