Problem
post_review_comment and post_draft_comment tools have no way to reply to an existing comment thread. Every comment is posted as a new standalone thread on the given line, even when the intent is to reply to a specific reviewer's comment.
This makes it impossible for AI agents to participate in code review conversations — replies appear as disconnected comments rather than threaded responses.
Root Cause
Two issues prevent in-thread replies:
1. No in_reply_to parameter
The Gerrit REST API supports an in_reply_to field in CommentInput that links a reply to its parent comment's UUID. Neither post_review_comment nor post_draft_comment expose this parameter.
2. Missing range matching for threaded comments
Even with in_reply_to set correctly, Gerrit UI does not render the reply in-thread unless the reply's positional metadata (range) matches the parent comment's position. This is because Gerrit identifies comment threads by (file, line, range) — not by in_reply_to alone.
When a reviewer highlights a code range and leaves a comment, the comment has a range field (e.g., {"start_line": 42, "start_character": 5, "end_line": 42, "end_character": 20}). A reply that only specifies line: 42 without the matching range creates a separate thread on the same line.
3. list_change_comments does not return comment IDs
To use in_reply_to, the caller needs the parent comment's UUID. The current list_change_comments output does not include comment IDs, so there is no way to obtain the value needed for in_reply_to.
Expected Behavior
When replying to a comment, the reply should appear inside the existing comment thread in the Gerrit UI, just as it would when using the "Reply" button in the web interface.
Proposed Fix
- Add
in_reply_to parameter to post_review_comment and post_draft_comment
- Auto-fetch parent comment's
range: When in_reply_to is provided, fetch the parent comment's metadata from /changes/{id}/comments and copy its range and line into the reply's CommentInput
- Include comment IDs in
list_change_comments output so callers can obtain the UUID needed for in_reply_to
Reproduction
# This creates a NEW thread on line 42, not a reply to comment abc123_def456
post_review_comment(
change_id="12345",
file_path="src/main.py",
line_number=42,
message="Done.",
in_reply_to="abc123_def456" # currently not supported
)
Environment
- Gerrit version: 3.x
- gerrit-mcp-server: master branch
Problem
post_review_commentandpost_draft_commenttools have no way to reply to an existing comment thread. Every comment is posted as a new standalone thread on the given line, even when the intent is to reply to a specific reviewer's comment.This makes it impossible for AI agents to participate in code review conversations — replies appear as disconnected comments rather than threaded responses.
Root Cause
Two issues prevent in-thread replies:
1. No
in_reply_toparameterThe Gerrit REST API supports an
in_reply_tofield inCommentInputthat links a reply to its parent comment's UUID. Neitherpost_review_commentnorpost_draft_commentexpose this parameter.2. Missing
rangematching for threaded commentsEven with
in_reply_toset correctly, Gerrit UI does not render the reply in-thread unless the reply's positional metadata (range) matches the parent comment's position. This is because Gerrit identifies comment threads by(file, line, range)— not byin_reply_toalone.When a reviewer highlights a code range and leaves a comment, the comment has a
rangefield (e.g.,{"start_line": 42, "start_character": 5, "end_line": 42, "end_character": 20}). A reply that only specifiesline: 42without the matchingrangecreates a separate thread on the same line.3.
list_change_commentsdoes not return comment IDsTo use
in_reply_to, the caller needs the parent comment's UUID. The currentlist_change_commentsoutput does not include comment IDs, so there is no way to obtain the value needed forin_reply_to.Expected Behavior
When replying to a comment, the reply should appear inside the existing comment thread in the Gerrit UI, just as it would when using the "Reply" button in the web interface.
Proposed Fix
in_reply_toparameter topost_review_commentandpost_draft_commentrange: Whenin_reply_tois provided, fetch the parent comment's metadata from/changes/{id}/commentsand copy itsrangeandlineinto the reply'sCommentInputlist_change_commentsoutput so callers can obtain the UUID needed forin_reply_toReproduction
Environment