Skip to main content
Glama
UtakataKyosui

PR Review MCP Server

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
NameRequiredDescriptionDefault
ownerYesRepository owner (username or organization)
repoYesRepository name
pull_numberYesPull request number
thread_idYesReview thread ID (from list_review_threads)
bodyYesReply content (Markdown supported)

Implementation Reference

  • 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))]
  • 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"],
        },
    ),
  • 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)
  • Top-level registration of all tools including reply_to_review_thread by calling register_tools on the MCP server.
    # Register tools
    register_tools(server)
  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/UtakataKyosui/PR-Review-Resolve-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server