reply_to_review_thread
Add a reply to a GitHub pull request review thread to address comments, provide clarification, or continue discussion 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 that extracts input arguments, retrieves the PR ID, adds a reply to the review thread using the GitHub API, formats the 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:42-65 (schema)Input schema definition for the tool, specifying required parameters: owner, repo, pull_number, thread_id, and body.Tool( name="reply_to_review_thread", description="Add a reply to a review thread", 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)Tool dispatch logic in the call_tool handler that routes calls to the specific reply_to_review_thread handler.elif name == "reply_to_review_thread": return await handle_reply_to_review_thread(api, arguments)
- src/pr_review_mcp/server.py:17-18 (registration)Top-level registration of all tools including reply_to_review_thread by calling register_tools on the MCP server.# Register tools register_tools(server)
- src/pr_review_mcp/gh_api.py:160-199 (helper)Supporting GitHub API helper that executes the 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