github-mcp-server icon indicating copy to clipboard operation
github-mcp-server copied to clipboard

[Reply To Review Comments] Add reply_to_review_comment tool for threaded PR review responses

Open lossyrob opened this issue 1 month ago • 0 comments

Add reply_to_review_comment Tool

Summary

This PR adds a new MCP tool reply_to_review_comment that enables AI agents to reply directly to individual pull request review comment threads. This maintains conversation context at specific code locations, allowing agents to participate in threaded code review discussions just as human developers do.

Problem: Previously, AI agents could only post general PR comments, which separated responses from the code they referenced and made review conversations fragmented.

Solution: The new tool provides direct access to GitHub's review comment reply API, allowing agents to respond within existing comment threads at specific code locations.

Related Issue

Closes https://github.com/github/github-mcp-server/issues/1323

Implementation Details

Core Changes

New Tool: reply_to_review_comment in pkg/github/pullrequests.go

  • Uses GitHub REST API: POST /repos/{owner}/{repo}/pulls/{pull_number}/comments
  • Calls client.PullRequests.CreateCommentInReplyTo() from go-github v79
  • Parameters: owner, repo, pull_number, comment_id, body
  • Returns MinimalResponse with reply ID and URL

Toolset Registration: Added to repository_management toolset as a write tool

Testing: Comprehensive unit tests with 10 test cases covering:

  • Successful reply creation (HTTP 201)
  • Error scenarios (404, 403, 422)
  • Parameter validation
  • Mock HTTP client for REST API testing

Technical Decisions

  • REST API over GraphQL: go-github provides a clean CreateCommentInReplyTo method
  • Required pull_number: GitHub API requires PR number in the endpoint path
  • int64 comment IDs: Uses RequiredBigInt validation for proper type handling
  • Single-reply operations: Agents orchestrate batch operations by calling the tool multiple times
  • Minimal response format: Returns only ID and URL, consistent with other create/update tools

Testing

Manual Testing Performed

Tested the tool in VS Code with the GitHub MCP Server:

  1. Created a test PR with review comments
  2. Retrieved comment IDs using pull_request_read with get_review_comments method
  3. Used reply_to_review_comment to respond to review comments
  4. Verified replies appeared as threaded responses in GitHub UI at correct code locations
  5. Confirmed notifications were sent to reviewers

Result: Tool works as expected - replies appear correctly threaded in the GitHub UI.

Automated Tests

  • All unit tests pass (script/test)
  • Linting passes with 0 issues (script/lint)
  • Toolsnap validation confirms schema stability
  • Documentation generated successfully

Documentation

  • README.md updated with tool documentation (auto-generated via script/generate-docs)
  • Tool parameters clearly documented with types and descriptions
  • Error handling documented for common failure scenarios

Project Artifacts

This implementation followed a structured development process. Supporting documentation is available in my fork:

Example Usage

{
  "owner": "myorg",
  "repo": "myproject",
  "pull_number": 42,
  "comment_id": 12345,
  "body": "Good point! I've renamed the variable to `userSessionManager` in commit abc123."
}

Response:

{
  "id": "67890",
  "url": "https://github.com/myorg/myproject/pull/42#discussion_r67890"
}

Breaking Changes

None - this is a new tool addition that doesn't affect existing tools or APIs.


🐾 Generated with PAW

lossyrob avatar Nov 20 '25 03:11 lossyrob