add_merge_request_discussion
Add comments to specific lines in GitLab merge request files to provide targeted feedback during code review.
Instructions
Add a discussion to a merge request at a specific position in a file.
Args:
project_id: The GitLab project ID or URL-encoded path
merge_request_iid: The merge request IID (project-specific ID)
body: The discussion text
position: Position data for the discussion.
Example:
{
"position_type": "text", // Required, Type of the position reference. Allowed values: text, image, or file. file introduced in GitLab 16.4.
"base_sha": "...", // Required, Base commit SHA in the source branch.
"start_sha": "...", // Required, SHA referencing commit in target branch.
"head_sha": "...", // Required, SHA referencing HEAD of this merge request.
"old_path": "path/to/file.py", // Required, File path before change.
"new_path": "path/to/file.py", // Required, File path after change.
"new_line": 15, // For text diff notes, the line number after change.
"old_line": 10 // For text diff notes, the line number before change.
}
Returns:
Dict containing the created discussion information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| merge_request_iid | Yes | ||
| body | Yes | ||
| position | Yes |
Input Schema (JSON Schema)
{
"properties": {
"body": {
"title": "Body",
"type": "string"
},
"merge_request_iid": {
"title": "Merge Request Iid",
"type": "string"
},
"position": {
"additionalProperties": true,
"title": "Position",
"type": "object"
},
"project_id": {
"title": "Project Id",
"type": "string"
}
},
"required": [
"project_id",
"merge_request_iid",
"body",
"position"
],
"type": "object"
}