reply_to_review_thread
Add responses to GitHub pull request review threads to address feedback and continue discussions on code changes.
Instructions
Add a reply to a review thread
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner (username or organization) | |
| repo | Yes | Repository name | |
| pull_number | Yes | Pull request number | |
| thread_id | Yes | Review thread ID (from list_review_threads) | |
| body | Yes | Reply content (Markdown supported) |
Implementation Reference
- src/pr_review_mcp/tools.py:170-197 (handler)Main handler function for the reply_to_review_thread tool. Extracts input arguments, retrieves PR ID, adds reply to the review thread via GitHub API, formats result as JSON, and returns it as TextContent.async def handle_reply_to_review_thread( api: GitHubAPI, arguments: dict[str, Any] ) -> list[TextContent]: """Handle reply_to_review_thread tool call.""" owner = arguments["owner"] repo = arguments["repo"] pull_number = arguments["pull_number"] thread_id = arguments["thread_id"] body = arguments["body"] # Get PR ID pr_id = api.get_pr_id(owner, repo, pull_number) # Add reply comment = api.add_thread_reply(pr_id, thread_id, body) result = { "success": True, "comment": { "id": comment.get("id"), "author": comment.get("author", {}).get("login"), "body": comment.get("body"), "created_at": comment.get("createdAt"), }, } return [TextContent(type="text", text=json.dumps(result, indent=2))]
- src/pr_review_mcp/tools.py:45-64 (schema)Input schema defining the parameters for the reply_to_review_thread tool: owner, repo, pull_number, thread_id, body with types and descriptions.inputSchema={ "type": "object", "properties": { "owner": { "type": "string", "description": "Repository owner (username or organization)", }, "repo": {"type": "string", "description": "Repository name"}, "pull_number": {"type": "integer", "description": "Pull request number"}, "thread_id": { "type": "string", "description": "Review thread ID (from list_review_threads)", }, "body": { "type": "string", "description": "Reply content (Markdown supported)", }, }, "required": ["owner", "repo", "pull_number", "thread_id", "body"], },
- src/pr_review_mcp/tools.py:113-114 (registration)Registration/dispatch logic in the MCP call_tool handler that maps the tool name to its specific handler function.elif name == "reply_to_review_thread": return await handle_reply_to_review_thread(api, arguments)
- src/pr_review_mcp/gh_api.py:160-199 (helper)Helper method in GitHubAPI class that executes GraphQL mutation to add a reply to a specific review thread.def add_thread_reply(self, pull_request_id: str, thread_id: str, body: str) -> dict[str, Any]: """ Add a reply to a review thread. Args: pull_request_id: Pull request node ID thread_id: Review thread node ID body: Reply content Returns: Created comment object """ query = """ mutation AddReply($pullRequestId: ID!, $threadId: ID!, $body: String!) { addPullRequestReviewThreadReply(input: { pullRequestId: $pullRequestId pullRequestReviewThreadId: $threadId body: $body }) { comment { id body createdAt author { login } } } } """ variables = {"pullRequestId": pull_request_id, "threadId": thread_id, "body": body} data = self.execute_graphql(query, variables) comment = data.get("addPullRequestReviewThreadReply", {}).get("comment", {}) if not comment: raise GitHubAPIError("Failed to create comment") return comment
- src/pr_review_mcp/gh_api.py:67-97 (helper)Helper method to retrieve the GraphQL node ID of the pull request, required for adding thread replies.def get_pr_id(self, owner: str, repo: str, pull_number: int) -> str: """ Get the node ID of a pull request. Args: owner: Repository owner repo: Repository name pull_number: Pull request number Returns: Pull request node ID """ query = """ query GetPRId($owner: String!, $repo: String!, $pullNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $pullNumber) { id } } } """ variables = {"owner": owner, "repo": repo, "pullNumber": pull_number} data = self.execute_graphql(query, variables) pr_id = data.get("repository", {}).get("pullRequest", {}).get("id") if not pr_id: raise GitHubAPIError(f"Pull request #{pull_number} not found") return pr_id