update_reviews
Submit a review for a GitHub pull request. Approve, request changes, or comment to provide feedback directly.
Instructions
Submits a review for a specific pull request in a GitHub repository. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. pr_number (int): The pull request number to review. event (Literal['APPROVE', 'REQUEST_CHANGES', 'COMMENT']): The type of review event. body (str, optional): Required when using REQUEST_CHANGES or COMMENT for the event parameter. Defaults to None. Returns: Dict[str, Any]: The JSON response from the GitHub API containing review information if successful. None: If an error occurs during the review submission process. Error Handling: Logs errors and prints the traceback if the review submission fails, returning None.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_owner | Yes | ||
| repo_name | Yes | ||
| pr_number | Yes | ||
| event | Yes | ||
| body | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The `update_reviews` handler method in `GitHubIntegration` class. Submits a pull request review via POST to GitHub's /repos/{owner}/{repo}/pulls/{pr_number}/reviews endpoint. Validates event type (APPROVE, REQUEST_CHANGES, COMMENT), optionally includes a body, and returns the API response.
def update_reviews( self, repo_owner: str, repo_name: str, pr_number: int, event: Literal["APPROVE", "REQUEST_CHANGES", "COMMENT"], body: str | None = None, ) -> dict[str, Any]: """ Submits a review for a specific pull request in a GitHub repository. Args: repo_owner (str): The owner of the repository. repo_name (str): The name of the repository. pr_number (int): The pull request number to review. event (Literal['APPROVE', 'REQUEST_CHANGES', 'COMMENT']): The type of review event. body (str, optional): Required when using REQUEST_CHANGES or COMMENT for the event parameter. Defaults to None. Returns: Dict[str, Any]: The JSON response from the GitHub API containing review information if successful. None: If an error occurs during the review submission process. Error Handling: Logs errors and prints the traceback if the review submission fails, returning None. """ logger.info(f"Submitting review for PR {repo_owner}/{repo_name}#{pr_number}") # Construct the reviews URL reviews_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/pulls/{pr_number}/reviews" try: response = httpx.post( reviews_url, headers=self._get_headers(), json={"body": body, "event": event}, timeout=TIMEOUT, ) self._raise_for_status(response, f"PR #{pr_number} review") review_data = response.json() logger.info("Review submitted successfully") return review_data except GitHubAuthError: raise except Exception as e: logger.error(f"Error submitting review: {str(e)}") traceback.print_exc() return {"status": "error", "message": str(e)} - src/mcp_github/issues_pr_analyser.py:137-148 (registration)Tools are registered dynamically in PRIssueAnalyser._register_tools() which calls self.register_tools(self.gi). The register_tools method iterates over all public methods of the GitHubIntegration instance (including update_reviews) and adds them as MCP tools via self.mcp.add_tool(method).
def _register_tools(self): self.register_tools(self.gi) self.register_tools(self.ip) self.mcp.add_provider(SkillsDirectoryProvider(Path(__file__).parent / "skills")) def register_tools(self, methods: Any = None) -> None: for name in dir(methods): if name.startswith("_"): continue method = getattr(methods, name) if inspect.isroutine(method): self.mcp.add_tool(method) - src/mcp_github/issues_pr_analyser.py:142-148 (registration)The register_tools method dynamically discovers and registers all public methods from a given object as MCP tools. Since GitHubIntegration has an update_reviews method, it gets registered as an MCP tool named 'update_reviews'.
def register_tools(self, methods: Any = None) -> None: for name in dir(methods): if name.startswith("_"): continue method = getattr(methods, name) if inspect.isroutine(method): self.mcp.add_tool(method)