Skip to content

Merge trains

A merge train queues merge requests into a target branch and tests each against the ones ahead of it before merging it. These actions list a project’s merge trains or the train of one target branch, read the train entry of a merge request, and add a merge request to its train.

  • “What is on the merge train for main?”
  • “Add merge request !15 to the merge train”
  • “Where is merge request !15 in the train?”
  • Dynamic, the default surface: call gitlab_execute_action with action set to the action’s ID, such as merge_train.add, and its parameters in params. gitlab_find_action finds an ID from a description of the task.
  • Meta (GITLAB_MCP_TOOL_SURFACE=meta): call gitlab_merge_train with action set to the action’s name, such as add, and its parameters in params.
  • Individual (GITLAB_MCP_TOOL_SURFACE=individual): call the action’s own tool, such as gitlab_add_merge_request_to_merge_train, with its parameters as the arguments.

How many of these actions an instance serves at each tier, out of a total of 4:

  • Free: 0
  • Premium: 4
  • Ultimate: 4

Read-only actions: 3 of 4, the ones a deployment in read-only mode keeps. A token with read_api and not api is served 3 of the 4.

The description of each action, and of each of its parameters, is the text the server serves for it on the default surface, quoted as served. The token lines say what GitLab 19.4.1 requires of a token for the requests each action sends; on an instance with Admin Mode turned on, an action only an administrator may run also needs admin_mode.

ActionIndividual
merge_train.addgitlab_add_merge_request_to_merge_train
merge_train.getgitlab_get_merge_request_on_merge_train
merge_train.list_branchgitlab_list_merge_request_in_merge_train
merge_train.list_projectgitlab_list_project_merge_trains

Add a merge request to a merge train. Returns: the resulting merge train entries with the merge request, user, pipeline, target branch, status, and duration. See also: merge_train.get, merge_train.list_branch, merge_train.list_project.

  • Meta-tool: gitlab_merge_train, action add
  • Individual tool: gitlab_add_merge_request_to_merge_train
  • Tier: Premium
  • Classic or OAuth token: api
  • Fine-grained token: Merge Train Merge Request: Add at project (permissions page)
  • Behavior: writes, not idempotent
ParameterTypeMandatoryDescription
merge_request_iidintegeryesMerge request internal ID
project_idstring/integeryesProject ID or URL-encoded path
auto_mergebooleannoEnable auto-merge when pipeline succeeds
shastringnoHead SHA of the merge request to verify
squashbooleannoSquash commits when merging
when_pipeline_succeedsbooleannoDeprecated in 17.11. Use auto_merge instead. Merge only when the pipeline succeeds

Get the merge train status of a single merge request. Returns: the merge train entry with the merge request, user, pipeline, target branch, status, and duration. See also: merge_train.list_project, merge_train.list_branch, merge_train.add.

  • Meta-tool: gitlab_merge_train, action get
  • Individual tool: gitlab_get_merge_request_on_merge_train
  • Tier: Premium
  • Classic or OAuth token: read_api (or api)
  • Fine-grained token: Merge Train: Read at project (permissions page)
  • Behavior: read-only, idempotent
ParameterTypeMandatoryDescription
merge_request_iidintegeryesMerge request internal ID
project_idstring/integeryesProject ID or URL-encoded path

List the merge requests on a merge train for a target branch. Returns: merge train entries with the merge request, user, pipeline, status, duration, and pagination metadata. See also: merge_train.list_project, merge_train.get, merge_train.add.

  • Meta-tool: gitlab_merge_train, action list_branch
  • Individual tool: gitlab_list_merge_request_in_merge_train
  • Tier: Premium
  • Classic or OAuth token: read_api (or api)
  • Fine-grained token: Merge Train: Read at project (permissions page)
  • Behavior: read-only, idempotent
ParameterTypeMandatoryDescription
project_idstring/integeryesProject ID or URL-encoded path
target_branchstringyesTarget branch name
order_bystringnoColumn to order results by (keyset pagination)
pageintegernoPage number to fetch, 1-based. Defaults to 1. Use the next_page field from the previous response to paginate forward.
page_tokenstringnoNext page of a keyset listing: the next_page_token of the previous response of this action, passed back unchanged. It carries the position and every filter of the listing as GitLab read them, and those are what the next page is asked with, whatever filters are sent beside it. Leave it empty for the first page.
paginationstringnoPagination method: ‘keyset’ for keyset-based pagination on large ordered result sets, or ‘offset’ (the default). Keyset avoids deep-offset cost, and a keyset page names the next one in next_page_token rather than next_page.
per_pageintegernoItems per page. Defaults to 20, minimum 1, maximum 100. Use 100 to minimize round trips when the result set is large.
scopestring (active, complete)noFilter by scope: active, complete
sortstring (asc, desc)noSort order: asc or desc

List all merge trains in a project. Returns: merge train entries with the merge request, user, pipeline, target branch, status, duration, and pagination metadata. See also: merge_train.list_branch, merge_train.get, merge_train.add.

  • Meta-tool: gitlab_merge_train, action list_project
  • Individual tool: gitlab_list_project_merge_trains
  • Tier: Premium
  • Classic or OAuth token: read_api (or api)
  • Fine-grained token: Merge Train: Read at project (permissions page)
  • Behavior: read-only, idempotent
ParameterTypeMandatoryDescription
project_idstring/integeryesProject ID or URL-encoded path
order_bystringnoColumn to order results by (keyset pagination)
pageintegernoPage number to fetch, 1-based. Defaults to 1. Use the next_page field from the previous response to paginate forward.
page_tokenstringnoNext page of a keyset listing: the next_page_token of the previous response of this action, passed back unchanged. It carries the position and every filter of the listing as GitLab read them, and those are what the next page is asked with, whatever filters are sent beside it. Leave it empty for the first page.
paginationstringnoPagination method: ‘keyset’ for keyset-based pagination on large ordered result sets, or ‘offset’ (the default). Keyset avoids deep-offset cost, and a keyset page names the next one in next_page_token rather than next_page.
per_pageintegernoItems per page. Defaults to 20, minimum 1, maximum 100. Use 100 to minimize round trips when the result set is large.
scopestring (active, complete)noFilter by scope: active, complete
sortstring (asc, desc)noSort order: asc or desc