Reviewmerge-requests
GET/repositories/{repo_id}/merge-requests/{mr_id}/stack
Reconstruct the stack a merge request belongs to
get_mr_stack
merge_request:read
A token needs themerge_request:readscope: View merge requestsGranted bymcp_agent,mcp_agent_write,read_api,read_repository,write_api,write_repository.Every operation this scope unlocks
A stack is a chain of merge requests, each targeting the branch of the one below it. Returns the path from the base branch up to this merge request, the tree of merge requests stacked on top of it, how many commits each is behind its target, and the stack's overall health: clean, out of date, needing a restack, degraded by a deleted branch, or looping back on itself.
Parameters
Path
- repo_idRepositoryId (string · uuid)Repository ID
- mr_idMergeRequestId (integer · int64)Merge request ID
Responses
200Stack reconstructedapplication/json
- anchor_mr_idMergeRequestId (integer · int64)
- base_branchBranchName (string)
downstackarray of StackNode
- The StackNode schema
- commits_behindinteger · int320–∞Advisory — how far behind its target this MR's source is.
- is_anchorboolean
- merge_request_idMergeRequestId (integer · int64)
- positioninteger · int320–∞
- restack_requiredbooleanPrecise — the MR's stored
restack_requiredmarker (squash downstack). - source_branchBranchName (string)
- statusMergeRequestStatusopenmergedclosed
- target_branchBranchName (string)
- titleMrTitle (string)
childrenarray of StackNodeoptionalUpstack dependents (a branch may have several). Empty in the
downstackpath.- The StackNode schema
- commits_behindinteger · int320–∞Advisory — how far behind its target this MR's source is.
- is_anchorboolean
- merge_request_idMergeRequestId (integer · int64)
- positioninteger · int320–∞
- restack_requiredbooleanPrecise — the MR's stored
restack_requiredmarker (squash downstack). - source_branchBranchName (string)
- statusMergeRequestStatusopenmergedclosed
- target_branchBranchName (string)
- titleMrTitle (string)
- childrenarray of StackNodeoptionalUpstack dependents (a branch may have several). Empty in the
downstackpath.
- repository_idRepositoryId (string · uuid)
- sizeinteger · int320–∞
- stack_healthStackHealthcleanout_of_dateneeds_restackdegradedcycle_detectedOverall health of a reconstructed stack.
upstackarray of StackNode
- The StackNode schema
- commits_behindinteger · int320–∞Advisory — how far behind its target this MR's source is.
- is_anchorboolean
- merge_request_idMergeRequestId (integer · int64)
- positioninteger · int320–∞
- restack_requiredbooleanPrecise — the MR's stored
restack_requiredmarker (squash downstack). - source_branchBranchName (string)
- statusMergeRequestStatusopenmergedclosed
- target_branchBranchName (string)
- titleMrTitle (string)
childrenarray of StackNodeoptionalUpstack dependents (a branch may have several). Empty in the
downstackpath.- The StackNode schema
- commits_behindinteger · int320–∞Advisory — how far behind its target this MR's source is.
- is_anchorboolean
- merge_request_idMergeRequestId (integer · int64)
- positioninteger · int320–∞
- restack_requiredbooleanPrecise — the MR's stored
restack_requiredmarker (squash downstack). - source_branchBranchName (string)
- statusMergeRequestStatusopenmergedclosed
- target_branchBranchName (string)
- titleMrTitle (string)
- childrenarray of StackNodeoptionalUpstack dependents (a branch may have several). Empty in the
downstackpath.
200 exampleSynthesized example
{
"anchor_mr_id": 42,
"base_branch": "feature/region-legend",
"downstack": [
{
"commits_behind": 3,
"is_anchor": false,
"merge_request_id": 42,
"position": 10,
"restack_required": false,
"source_branch": "feat/run-header-stream",
"status": "open",
"target_branch": "main",
"title": "Label every synthesized example"
}
],
"repository_id": "5b0e7c2a-9d14-4e8b-a6f1-2c3d4e5f6a70",
"size": 3,
"stack_health": "clean",
"upstack": [
{
"commits_behind": 5,
"is_anchor": false,
"merge_request_id": 42,
"position": 59,
"restack_required": false,
"source_branch": "feat/run-header-stream",
"status": "open",
"target_branch": "main",
"title": "Pin a page's payload to the build that rendered it"
},
{
"commits_behind": 5,
"is_anchor": false,
"merge_request_id": 42,
"position": 36,
"restack_required": false,
"source_branch": "refactor/brand-inline",
"status": "open",
"target_branch": "main",
"title": "Pin a page's payload to the build that rendered it"
}
]
}
400Bad request — a path parameter is not a well-formed value of its typeapplication/json
Error codes
- BAD_REQUESTThe request is malformed: a parameter or a body field is not a well-formed value of its type
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
400 exampleSynthesized example
{
"error": {
"code": "code-a96c",
"message": "Inline scalar newtypes but keep their brand"
}
}
401Unauthenticated — no credential, or an invalid oneapplication/json
Error codes
- UNAUTHORIZEDNo credential was sent, or the one sent is invalid, expired or revoked
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
401 exampleSynthesized example
{
"error": {
"code": "code-9b61",
"message": "Pin a page's payload to the build that rendered it"
}
}
403Forbidden — the caller's access level or token scope is insufficientapplication/json
Error codes
- FORBIDDENYou are signed in but may not do this here;
reasonnames the permission or the rule that refused it - INSUFFICIENT_SCOPEThe access token lacks the scope this operation needs;
required_scopenames it - PERMISSION_REQUIREDYou need a permission you do not hold here; the message names it
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
403 exampleSynthesized example
{
"error": {
"code": "code-2cc6",
"message": "Pin a page's payload to the build that rendered it"
}
}
404Merge request not foundapplication/json
Error codes
- NOT_FOUNDThe resource does not exist — or exists and you cannot see it: a private resource you have no access to answers exactly as an absent one does
errorErrorBody
- The ErrorBody schema
- codestringThe coarse category, tied to the status:
NOT_FOUND,CONFLICT,INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all. - messagestringWhat went wrong, for a person. Written to be read, not parsed: match on
reasonorcode. - fieldstring or nulloptionalOn a
400that refused one field's value, the field, as its JSON path:email,items[0].name. Put the message under that input. Absent on every other error. - reasonstring or nulloptionalThe specific code, when the error has one:
LAST_ORGANIZATION_OWNER,BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and oncodeotherwise. - required_scopestring or nulloptionalThe scope the access token was missing, on
INSUFFICIENT_SCOPE. - violationsanyoptionalPresent on the structured-validation errors (
PROVIDER_VALIDATION_FAILEDper-node,PIPELINE_VALIDATION_FAILEDDAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
404 exampleSynthesized example
{
"error": {
"code": "code-8c7c",
"message": "Stream pipeline status into the run header"
}
}
CLI
gitmoap mr get-stack
- --repo-ididRepository ID (id or owner/repo path)
- --mr-ididMerge request ID