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.

ParameterTypeRequiredDescription
project_idstringYesID or full path of the project.
merge_request_iidintegerNoInternal ID of the merge request. Provide to update an existing merge request; omit to create one.
titlestringNoTitle of the merge request. Required when creating.
source_branchstringNoName of the source branch. Required when creating.
target_branchstringNoName of the target branch. Required when creating.
target_project_idintegerNoID of the target project. Applies when creating.
descriptionstringNoDescription of the merge request.
labelsarray of stringsNoLabel names. Replaces all existing labels. Pass an empty array to remove all labels.
add_labelsarray of stringsNoLabel names to add. Applies when updating.
remove_labelsarray of stringsNoLabel names to remove. Applies when updating.
assigneesarray of stringsNoUsernames to assign. Alternative to assignee_ids; provide one. Pass an empty array to remove all assignees.
assignee_idsarray of integersNoUser IDs to assign. Alternative to assignees; provide one. Pass an empty array to remove all assignees.
reviewersarray of stringsNoUsernames to request review from. Alternative to reviewer_ids; provide one. Pass an empty array to remove all reviewers.
reviewer_idsarray of integersNoUser IDs to request review from. Alternative to reviewers; provide one. Pass an empty array to remove all reviewers.
milestone_idintegerNoID of the milestone.
milestonestringNoTitle of a project or ancestor-group milestone to assign. Mutually exclusive with milestone_id.
remove_source_branchbooleanNoRemove the source branch when the merge request is merged.
squashbooleanNoSquash commits into a single commit when merging.
state_eventstringNoState transition to perform. One of close or reopen. Applies when updating.
discussion_lockedbooleanNoLock the merge request discussion. Applies when updating.
allow_collaborationbooleanNoAllow 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 squash
Update merge request 42 in project gitlab-org/gitlab to add the "bug" label and close it

get_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.

ParameterTypeRequiredDescription
urlstringNoGitLab URL of the merge request. Provide this, or project_id and merge_request_iid.
project_idstringNoID or full path of the project. Required if url is missing.
merge_request_iidintegerNoInternal ID of the merge request. Required if url is missing.
includearrayNoAssociated 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.
detailstringNoLevel 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_afterstringNoCursor for forward pagination of files. Applies only when include contains diffs and detail is full_patch.
diffs_firstintegerNoNumber of files to return after the cursor, up to 100. Applies only when include contains diffs and detail is full_patch.
notes_afterstringNoCursor for forward pagination of notes. Applies only when include contains notes.
notes_firstintegerNoNumber of notes to return after the cursor, up to 100. Applies only when include contains notes.
notes_beforestringNoCursor for backward pagination of notes. Applies only when include contains notes.
notes_lastintegerNoNumber of notes to return before the cursor, up to 100. Applies only when include contains notes.
commits_afterstringNoCursor for forward pagination of commits. Applies only when include contains commits.
commits_firstintegerNoNumber of commits to return after the cursor, up to 100. Applies only when include contains commits.
pipelines_afterstringNoCursor for forward pagination of pipelines. Applies only when include contains pipelines.
pipelines_firstintegerNoNumber 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 commits

list_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.

ParameterTypeRequiredDescription
urlstringNoGitLab URL of the project or group. Provide exactly one of url, project_id, or group_id.
project_idstringNoID or full path of the project. Provide exactly one of url, project_id, or group_id.
group_idstringNoID or full path of the group. Provide exactly one of url, project_id, or group_id.
author_usernamestringNoFilter by the username of the merge request author.
assignee_usernamestringNoFilter by the username of an assignee.
reviewer_usernamestringNoFilter by the username of a reviewer.
reviewer_wildcard_idstringNoFilter 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.
statestringNoFilter by state. One of opened, closed, merged, locked, or all. Omit to include any state.
scopestringNoFilter relative to the authenticated user. One of created_by_me, assigned_to_me, or review_requested. An explicit username wins for that field.
milestonestringNoFilter by the title of the milestone.
labelsstringNoComma-separated list of label names. Only merge requests with all of these labels are returned.
searchstringNoSearch query matched against merge request title and description.
afterstringNoCursor for forward pagination.
firstintegerNoNumber 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/gitlab

get_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.

ParameterTypeRequiredDescription
idstringYesID or full path of the project.
merge_request_iidintegerYesInternal ID of the merge request.
per_pageintegerNoNumber of commits per page.
pageintegerNoCurrent page number.

Example:

Show me all commits in merge request 42 from project 123

get_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.

ParameterTypeRequiredDescription
idstringYesID or full path of the project.
merge_request_iidintegerYesInternal ID of the merge request.
per_pageintegerNoNumber of diffs per page.
pageintegerNoCurrent 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.

ParameterTypeRequiredDescription
idstringYesID or full path of the project.
merge_request_iidintegerYesInternal ID of the merge request.

Example:

Show me all pipelines for merge request 42 in project gitlab-org/gitlab

get_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.

ParameterTypeRequiredDescription
project_idstringYesID or full path of the project (for example, gitlab-org/gitlab).
merge_request_iidintegerYesInternal 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/gitlab

get_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.

ParameterTypeRequiredDescription
urlstringNoURL of the GitLab merge request. Required if project_id and merge_request_iid are missing.
project_idstringNoID or full path of the project. Required if url is missing.
merge_request_iidintegerNoInternal ID of the merge request. Required if url is missing.
afterstringNoCursor for forward pagination.
beforestringNoCursor for backward pagination.
firstintegerNoNumber of notes to return for forward pagination.
lastintegerNoNumber 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/gitlab

save_merge_request_review

Writes merge request review artifacts as the authenticated user. Each call performs exactly one operation, selected with the method parameter:

MethodAction
create_noteAdds a top-level comment.
reply_discussionReplies in an existing discussion.
create_diff_noteComments on a specific diff line.
resolve_discussionResolves or unresolves a discussion.
update_noteReplaces the text of a note on the merge request. You must be the note author or have at least the Maintainer role.
submit_reviewPosts multiple diff comments and an optional summary in one call.
post_duo_reviewAsks GitLab Duo to review the merge request. Requires GitLab Duo Code Review.
approveApproves the merge request. Already-approved calls succeed with status already_approved.
unapproveRemoves 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.

ParameterTypeRequiredDescription
urlstringNoURL of the GitLab merge request, or a comment link ending in #note_<id>. Required if project_id and merge_request_iid are missing.
project_idstringNoID or path of the project. Required if url is missing.
merge_request_iidintegerNoInternal ID of the merge request. Required if url is missing.
methodstringYesThe operation to perform. Parameters that belong to a different method are rejected.
bodystringNoNote 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_idstringNoDiscussion to act on. Required for reply_discussion and resolve_discussion. Accepts a global ID or a bare discussion ID.
note_idintegerNoNote 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.
internalbooleanNoFor create_note, marks the note as internal.
resolvedbooleanNoFor resolve_discussion: true resolves, false unresolves. Required for that method.
old_pathstringNoFor create_diff_note, the file path before the change. Provide old_path or new_path, or both.
new_pathstringNoFor create_diff_note, the file path after the change.
old_lineintegerNoFor create_diff_note, the line number in the old version. Provide old_line or new_line, or both.
new_lineintegerNoFor create_diff_note, the line number in the new version.
commentsarrayNoFor 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.
verdictstringNoFor submit_review, an overall verdict prefixed to the summary note.
summarystringNoFor submit_review, a summary note posted after the diff comments.
summary_internalbooleanNoFor submit_review, marks the summary note as internal.
shastringNoFor 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 summary

accept_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.

ParameterTypeRequiredDescription
urlstringNoGitLab URL of the merge request. Provide this, or project_id and merge_request_iid.
project_idstringNoID or path of the project. Required if url is missing.
merge_request_iidintegerNoInternal ID of the merge request. Required if url is missing.
shastringYesHead SHA guard. When it no longer matches the merge request head, the merge is refused. Pass the diffHeadSha returned by get_merge_request.
strategystringNoAuto-merge strategy, for example merge_when_checks_pass. When given, arms auto-merge instead of merging immediately.
squashbooleanNoSquash the commits into a single commit on merge.
commit_messagestringNoCustom merge commit message.
squash_commit_messagestringNoCustom squash commit message. Applies when squash is true.
should_remove_source_branchbooleanNoRemove the source branch after merging.

Example:

Merge merge request 42 in project gitlab-org/gitlab once its checks pass, and remove the source branch

apply_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:

  • id
  • from_line
  • to_line
  • appliable
  • applied
  • from_content
  • to_content

The call fails with one of the following statuses:

  • 404 when the suggestion doesn’t exist.
  • 403 when 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.
  • 400 when the suggestion can’t be applied, for example because the line changed in a more recent version of the merge request.
ParameterTypeRequiredDescription
idintegerYesID of the suggestion.
commit_messagestringNoCustom commit message. Replaces the generated message or the project’s commit message for applied suggestions.

Example:

Apply suggestion 123