reply_to_review_comment
Respond to specific discussion threads in merge request reviews by adding comments that address feedback and continue code review conversations.
Instructions
Reply to a specific discussion thread in a merge request review
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| merge_request_iid | Yes | Internal ID of the merge request | |
| discussion_id | Yes | ID of the discussion thread to reply to | |
| body | Yes | Content of the reply comment |
Input Schema (JSON Schema)
{
"properties": {
"body": {
"description": "Content of the reply comment",
"type": "string"
},
"discussion_id": {
"description": "ID of the discussion thread to reply to",
"type": "string"
},
"merge_request_iid": {
"description": "Internal ID of the merge request",
"minimum": 1,
"type": "integer"
}
},
"required": [
"merge_request_iid",
"discussion_id",
"body"
],
"type": "object"
}
Implementation Reference
- tools/reply_to_review_comment.py:12-54 (handler)The core handler function implementing the reply_to_review_comment tool. It extracts arguments, calls the GitLab API helper to post the reply, formats success/error responses as TextContent.async def reply_to_review_comment(gitlab_url, project_id, access_token, args): """Reply to a specific discussion thread in a merge request review""" logging.info(f"reply_to_review_comment called with args: {args}") mr_iid = args["merge_request_iid"] discussion_id = args["discussion_id"] reply_body = args["body"] try: status, response_data, error_text = await reply_to_merge_request_discussion( gitlab_url, project_id, access_token, mr_iid, discussion_id, reply_body ) if status == 201: author_name = response_data.get("author", {}).get("name", "Unknown") note_id = response_data.get("id", "unknown") result = "✅ **Reply posted successfully!**\n\n" result += f"**Merge Request**: !{mr_iid}\n" result += f"**Discussion ID**: `{discussion_id}`\n" result += f"**Note ID**: `{note_id}`\n" result += f"**Author**: {author_name}\n" reply_preview = reply_body[:100] + ("..." if len(reply_body) > 100 else "") result += f"**Reply**: {reply_preview}\n" return [TextContent(type="text", text=result)] else: error_msg = "❌ **Error posting reply**\n\n" error_msg += f"**Status**: {status}\n" error_msg += f"**Error**: {error_text}\n" error_msg += f"**MR**: !{mr_iid}\n" error_msg += f"**Discussion**: {discussion_id}\n" return [TextContent(type="text", text=error_msg)] except Exception as e: logging.error(f"Unexpected error in reply_to_review_comment: {e}") error_result = "❌ **Unexpected error**\n\n" error_result += f"**Error**: {str(e)}\n" error_result += f"**MR**: !{mr_iid}\n" error_result += f"**Discussion**: {discussion_id}\n" return [TextContent(type="text", text=error_result)]
- main.py:193-212 (schema)The Tool object definition including inputSchema for validating parameters of reply_to_review_comment, provided by the list_tools() handler.Tool( name="reply_to_review_comment", description=("Reply to a specific discussion thread in a " "merge request review"), inputSchema={ "type": "object", "properties": { "merge_request_iid": { "type": "integer", "minimum": 1, "description": ("Internal ID of the merge request"), }, "discussion_id": { "type": "string", "description": ("ID of the discussion thread to reply to"), }, "body": {"type": "string", "description": "Content of the reply comment"}, }, "required": ["merge_request_iid", "discussion_id", "body"], "additionalProperties": False, },
- main.py:331-334 (registration)Dispatch/registration logic in the call_tool() handler that routes calls to the reply_to_review_comment function with config parameters.elif name == "reply_to_review_comment": return await reply_to_review_comment( self.config["gitlab_url"], self.config["project_id"], self.config["access_token"], arguments )