Skip to main content
Glama

github_get_pull_requests

Retrieve pull requests from GitHub repositories to monitor code changes, review contributions, and track development progress. Filter by open, closed, or all states with customizable result limits.

Instructions

Get pull requests for a GitHub repository.

Args: repo_name: Full repository name (e.g., "owner/repo") state: PR state: "open", "closed", or "all" (default: "open") limit: Maximum number of PRs to return (default: 20)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
repo_nameYes
stateNoopen

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'github_get_pull_requests', registered with @mcp.tool() decorator and delegates execution to GitHubTools.get_pull_requests
    @mcp.tool()
    async def github_get_pull_requests(
        repo_name: str, state: str = "open", limit: int = 20
    ) -> list:
        """Get pull requests for a GitHub repository.
    
        Args:
            repo_name: Full repository name (e.g., "owner/repo")
            state: PR state: "open", "closed", or "all" (default: "open")
            limit: Maximum number of PRs to return (default: 20)
        """
        return await github_tools.get_pull_requests(
            repo_name=repo_name, state=state, limit=limit
        )
  • Core helper function in GitHubTools class that implements the pull requests fetching logic using PyGithub library
    async def get_pull_requests(
        self, repo_name: str, state: str = "open", limit: int = 20
    ) -> List[Dict[str, Any]]:
        """
        Get pull requests for a repository.
    
        Args:
            repo_name: Full repository name (e.g., "owner/repo")
            state: PR state ("open", "closed", or "all")
            limit: Maximum number of PRs to return
    
        Returns:
            List of pull request information
        """
        self._check_client()
    
        try:
            repo = self.client.get_repo(repo_name)
            pulls = repo.get_pulls(state=state)
    
            results = []
            for i, pr in enumerate(pulls):
                if i >= limit:
                    break
                results.append(
                    {
                        "number": pr.number,
                        "title": pr.title,
                        "state": pr.state,
                        "user": pr.user.login,
                        "created_at": (
                            pr.created_at.isoformat() if pr.created_at else None
                        ),
                        "updated_at": (
                            pr.updated_at.isoformat() if pr.updated_at else None
                        ),
                        "url": pr.html_url,
                        "head": pr.head.ref,
                        "base": pr.base.ref,
                    }
                )
    
            return results
    
        except GithubException as e:
            logger.error(f"GitHub API error: {e}")
            raise ValueError(f"Failed to get pull requests: {str(e)}")
  • JSON schema definition for the tool input used in the LLM assistant integration
    {
        "name": "github_get_pull_requests",
        "description": "Get pull requests for a GitHub repository",
        "input_schema": {
            "type": "object",
            "properties": {
                "repo_name": {
                    "type": "string",
                    "description": "Full repository name",
                },
                "state": {
                    "type": "string",
                    "enum": ["open", "closed", "all"],
                    "default": "open",
                },
                "limit": {
                    "type": "integer",
                    "description": "Maximum PRs",
                    "default": 20,
                },
            },
            "required": ["repo_name"],
        },
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions default values for 'state' and 'limit', which is helpful, but fails to describe critical behaviors like authentication requirements, rate limits, pagination, error handling, or the format of returned data. For a tool that likely interacts with an external API, this is a significant gap.

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

Conciseness5/5

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

The description is front-loaded with the core purpose in the first sentence, followed by a well-structured 'Args' section that lists parameters clearly with examples and defaults. Every sentence earns its place, with no redundant or verbose language, making it efficient and easy to parse.

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

Completeness3/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), the description covers the purpose and parameters well, and an output schema exists, so return values need not be explained. However, it lacks context on authentication, error cases, or sibling tool differentiation, which are important for a GitHub API tool. It's adequate but has clear gaps.

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

Parameters4/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. It effectively explains all three parameters: 'repo_name' as the full repository name with an example, 'state' with its allowed values and default, and 'limit' with its purpose and default. This adds substantial meaning beyond the bare schema, though it could include more details like constraints on 'limit'.

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

Purpose4/5

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

The description clearly states the tool's purpose as 'Get pull requests for a GitHub repository' with a specific verb ('Get') and resource ('pull requests'), making it immediately understandable. However, it does not explicitly differentiate from sibling tools like 'github_search_code' or 'github_list_repositories', which could also involve repository data but for different resources.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, such as 'github_search_code' for code-specific queries or 'github_list_repositories' for broader repository info. It lacks context about prerequisites (e.g., authentication needs) or typical use cases, leaving the agent to infer usage based on the purpose alone.

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/bsangars/mcp'

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