Skip to main content
Glama
saidsef

GitHub PR Issue Analyser

by saidsef

update_reviews

Submit reviews for GitHub pull requests to approve changes, request modifications, or add comments. This tool automates code review feedback within the GitHub PR Issue Analyser server.

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

TableJSON Schema
NameRequiredDescriptionDefault
repo_ownerYes
repo_nameYes
pr_numberYes
eventYes
bodyNo

Implementation Reference

  • The handler function that implements the core logic of the 'update_reviews' MCP tool. It sends a POST request to GitHub's pull request reviews API endpoint to submit a review with the specified event type and optional body comment.
    def update_reviews(self, repo_owner: str, repo_name: str, pr_number: int, event: Literal['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], body: Optional[str] = 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.
        """
        logging.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 = requests.post(reviews_url, headers=self._get_headers(), json={
                'body': body,
                'event': event
            }, timeout=TIMEOUT)
            response.raise_for_status()
            review_data = response.json()
    
            logging.info("Review submitted successfully")
            return review_data
    
        except Exception as e:
            logging.error(f"Error submitting review: {str(e)}")
            traceback.print_exc()
            return {"status": "error", "message": str(e)}
  • The registration code that dynamically registers all public methods of the GitHubIntegration instance (including 'update_reviews') as MCP tools by iterating over methods and calling mcp.add_tool() on each.
    def _register_tools(self):
        self.register_tools(self.gi)
        self.register_tools(self.ip)
    
    def register_tools(self, methods: Any = None) -> None:
        for name, method in inspect.getmembers(methods):
            if (inspect.isfunction(method) or inspect.ismethod(method)) and not name.startswith("_"):
                self.mcp.add_tool(method)
  • Import of the GitHubIntegration class, which contains the update_reviews handler, making it available for registration as an MCP tool.
    from .github_integration import GitHubIntegration as GI

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/saidsef/mcp-github-pr-issue-analyser'

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