Skip to main content
Glama
saidsef

GitHub PR Issue Analyser

by saidsef

get_pr_content

Fetch pull request details from GitHub repositories to analyze content, author information, and status for review or integration workflows.

Instructions

Fetches the content/details of a specific pull request from 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. Returns: Dict[str, Any]: A dictionary containing the pull request's title, description, author, creation and update timestamps, and state. Returns None if an error occurs during the fetch operation. Error Handling: Logs an error message and prints the traceback if the request fails or an exception is raised during processing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_ownerYes
repo_nameYes
pr_numberYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that executes the get_pr_content tool logic. Fetches PR details (title, body, author, created_at, updated_at, state) from GitHub API endpoint /repos/{owner}/{repo}/pulls/{pr_number}, extracts key fields, handles errors by returning error dict.
    def get_pr_content(self, repo_owner: str, repo_name: str, pr_number: int) -> Dict[str, Any]:
        """
        Fetches the content/details of a specific pull request from 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.
        Returns:
            Dict[str, Any]: A dictionary containing the pull request's title, description, author, creation and update timestamps, and state.
            Returns None if an error occurs during the fetch operation.
        Error Handling:
            Logs an error message and prints the traceback if the request fails or an exception is raised during processing.
        """
        logging.info(f"Fetching PR content for {repo_owner}/{repo_name}#{pr_number}")
        
        # Construct the PR URL
        pr_url = self._get_pr_url(repo_owner, repo_name, pr_number)
        
        try:
            # Fetch PR details
            response = requests.get(pr_url, headers=self._get_headers(), timeout=TIMEOUT)
            response.raise_for_status()
            pr_data = response.json()
            
            # Extract relevant information
            pr_info = {
                'title': pr_data['title'],
                'description': pr_data['body'],
                'author': pr_data['user']['login'],
                'created_at': pr_data['created_at'],
                'updated_at': pr_data['updated_at'],
                'state': pr_data['state']
            }
    
            logging.info("Successfully fetched PR content")
            return pr_info
            
        except Exception as e:
            logging.error(f"Error fetching PR content: {str(e)}")
            traceback.print_exc()
            return {"status": "error", "message": str(e)}
  • Registers all public methods of GitHubIntegration instance (self.gi) as MCP tools using FastMCP.add_tool in a loop over inspect.getmembers. This automatically registers get_pr_content since it does not start with underscore.
        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)
  • Helper method used by get_pr_content to construct the GitHub API URL: https://api.github.com/repos/{repo_owner}/{repo_name}/pulls/{pr_number}
    def _get_pr_url(self, repo_owner: str, repo_name: str, pr_number: int) -> str:
        """
        Construct the GitHub API URL for a specific pull request.
        Args:
            repo_owner (str): The owner of the GitHub repository.
            repo_name (str): The name of the GitHub repository.
            pr_number (int): The pull request number.
        Returns:
            str: The formatted GitHub API URL for the specified pull request.
        Raises:
            ValueError: If any of the arguments are empty or if pr_number is not a positive integer.
        """
        url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/pulls/{pr_number}"
        return url
  • Helper method used by get_pr_content to generate HTTP headers with GitHub token authorization and v3 API accept header.
    def _get_headers(self):
        """
        Constructs the HTTP headers required for GitHub API requests, including the authorization token.
        Returns:
            dict: A dictionary containing the required HTTP headers.
        Error Handling:
            Raises ValueError if the GitHub token is not set.
        """
        if not self.github_token:
            raise ValueError("GitHub token is missing for API requests")
        headers = {
            'Authorization': f'token {self.github_token}',
            'Accept': 'application/vnd.github.v3+json'
        }
        return headers
  • Instantiates the GitHubIntegration instance (self.gi = GI()) whose methods, including get_pr_content, will be registered as MCP tools.
    self.gi = GI()
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the return value structure (title, description, author, timestamps, state) and error handling (returns None on error, logs error and traceback). This adds significant value beyond the input schema, covering output behavior and error management, though it doesn't mention rate limits or authentication needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections for Args, Returns, and Error Handling, making it easy to scan. It's appropriately sized at about 100 words, with each sentence adding value (e.g., specifying return content and error behavior). However, it could be slightly more front-loaded by moving the Args section after the initial sentence for better flow.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no annotations, but has output schema), the description is complete enough. It covers purpose, parameters, return values, and error handling comprehensively. Since an output schema exists, the description doesn't need to detail return values further, and it adequately addresses the lack of annotations by describing behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate fully. It explicitly lists and explains all three parameters (repo_owner, repo_name, pr_number) in the 'Args' section, adding clear meaning beyond the schema's basic titles. This provides complete parameter semantics, making the tool easy to use correctly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Fetches the content/details') and resource ('a specific pull request from a GitHub repository'), distinguishing it from siblings like get_pr_diff (which focuses on diff content) or list_open_issues_prs (which lists multiple items). The verb 'fetches' is precise and the scope is well-defined.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by specifying it's for a 'specific pull request,' suggesting it should be used when you have a known PR number. However, it doesn't explicitly state when to use this versus alternatives like get_pr_diff or list_open_issues_prs, nor does it mention prerequisites or exclusions. The context is clear but lacks explicit guidance on alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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