Apply merge request suggestion
apply_merge_request_suggestionApply a specific GitLab code suggestion to a merge request after verifying it belongs to the project, is still applicable, and the MR head matches your reviewed version. Requires explicit acknowledgement to commit the change.
Instructions
Apply a single GitLab code suggestion by its suggestion ID. Performs preflight validation: confirms the suggestion belongs to the specified project/MR, is still applicable, has not already been applied, and that the MR head SHA matches the caller's expected value. Uses the Suggestions API at PUT /suggestions/:id/apply. Returns the suggestion state including applicable and applied flags. An explicit acknowledgement is required to apply. Note: GitLab's apply endpoint does not accept an expected-head parameter, so a TOCTOU race is possible between preflight and mutation; the server remains authoritative at mutation time.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project": "<project>",
"merge_request_iid": "<merge_request_iid>",
"suggestion_id": "<suggestion_id>",
"expected_head_sha": "<expected_head_sha>",
"acknowledge": "<acknowledge>"
},
"name": "apply_merge_request_suggestion"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | GitLab project ID or full path such as group/project. | |
| acknowledge | Yes | Must be true to confirm the suggestion should be applied. | |
| suggestion_id | Yes | ||
| commit_message | No | ||
| expected_head_sha | Yes | The MR head SHA the caller last reviewed. The tool rejects the mutation if the current MR head differs. | |
| merge_request_iid | Yes | Project-scoped internal ID. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes | GitLab response normalized for model use. |