Skip to main content
Glama
MementoRC

MCP Git Server

by MementoRC

github_list_pull_requests

Retrieve and filter pull requests from a GitHub repository with options to sort, paginate, and filter by state, head, and base branch using the MCP Git Server.

Instructions

List pull requests for a repository with filtering and pagination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baseNo
directionNodesc
headNo
pageNo
per_pageNo
repo_nameYes
repo_ownerYes
sortNocreated
stateNoopen

Implementation Reference

  • The main handler function that executes the tool: calls GitHub API to list PRs with filtering/pagination, handles errors, formats output with emojis and details.
    async def github_list_pull_requests(
        repo_owner: str,
        repo_name: str,
        state: str = "open",
        head: str | None = None,
        base: str | None = None,
        sort: str = "created",
        direction: str = "desc",
        per_page: int = 30,
        page: int = 1,
    ) -> str:
        """List pull requests for a repository"""
        logger.debug(f"🔍 Starting github_list_pull_requests for {repo_owner}/{repo_name}")
    
        try:
            async with github_client_context() as client:
                logger.debug("✅ GitHub client obtained successfully")
                logger.debug(
                    f"🔗 Token prefix: {client.token[:8]}..."
                    if client.token
                    else "No token"
                )
    
                params = {
                    "state": state,
                    "sort": sort,
                    "direction": direction,
                    "per_page": per_page,
                    "page": page,
                }
    
                if head:
                    params["head"] = head
                if base:
                    params["base"] = base
    
                logger.debug(
                    f"📡 Making API call to /repos/{repo_owner}/{repo_name}/pulls with params: {params}"
                )
    
                response = await client.get(
                    f"/repos/{repo_owner}/{repo_name}/pulls", params=params
                )
    
                logger.debug(f"📨 GitHub API response status: {response.status}")
    
                if response.status == 401:
                    response_text = await response.text()
                    logger.error(
                        f"🔒 GitHub API authentication failed (401): {response_text}"
                    )
                    return f"❌ GitHub API error 401: {response_text}"
                elif response.status != 200:
                    response_text = await response.text()
                    logger.error(f"❌ GitHub API error {response.status}: {response_text}")
                    return f"❌ Failed to list pull requests: {response.status} - {response_text}"
    
                prs = await response.json()
    
                if not prs:
                    return f"No {state} pull requests found"
    
                output = [f"{state.title()} Pull Requests for {repo_owner}/{repo_name}:\n"]
    
                for pr in prs:
                    state_emoji = {"open": "🟢", "closed": "🔴", "merged": "🟣"}.get(
                        pr.get("state"), "❓"
                    )
                    output.append(f"{state_emoji} #{pr['number']}: {pr['title']}")
                    output.append(f"   Author: {pr.get('user', {}).get('login', 'N/A')}")
                    base_ref = pr.get("base", {}).get("ref", "N/A")
                    head_ref = pr.get("head", {}).get("ref", "N/A")
                    output.append(f"   Base: {base_ref} ← Head: {head_ref}")
                    output.append(f"   Created: {pr.get('created_at', 'N/A')}")
                    output.append("")
    
                return "\n".join(output)
    
        except ValueError as auth_error:
            logger.error(f"Authentication error listing pull requests: {auth_error}")
            return f"❌ {str(auth_error)}"
        except ConnectionError as conn_error:
            logger.error(f"Connection error listing pull requests: {conn_error}")
            return f"❌ Network connection failed: {str(conn_error)}"
        except Exception as e:
            logger.error(
                f"Unexpected error listing pull requests for {repo_owner}/{repo_name}: {e}",
                exc_info=True,
            )
            return f"❌ Error listing pull requests: {str(e)}"
  • Pydantic input schema/model defining parameters for the github_list_pull_requests tool.
    class GitHubListPullRequests(BaseModel):
        repo_owner: str
        repo_name: str
        state: str = "open"
        head: str | None = None
        base: str | None = None
        sort: str = "created"
        direction: str = "desc"
        per_page: int = 30
        page: int = 1
  • Tool registration in the central ToolRegistry, defining name, description, schema, and metadata. Actual handler set later via router.
    ToolDefinition(
        name=GitTools.GITHUB_LIST_PULL_REQUESTS,
        category=ToolCategory.GITHUB,
        description="List pull requests for a repository",
        schema=GitHubListPullRequests,
        handler=placeholder_handler,
        requires_repo=False,
        requires_github_token=True,
    ),
Behavior2/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 mentions 'filtering and pagination' but doesn't explain what filtering options exist, how pagination works (e.g., default page size, limits), rate limits, authentication requirements, or what the output looks like. For a tool with 9 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 a single, efficient sentence that front-loads the core purpose ('List pull requests for a repository') and adds key features ('with filtering and pagination'). There's no wasted language or redundancy, making it appropriately concise for the tool's complexity.

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

Completeness2/5

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

Given the tool's complexity (9 parameters, no annotations, no output schema), the description is incomplete. It doesn't cover parameter details, behavioral traits like rate limits or authentication, output format, or differentiation from siblings. For a list operation with rich filtering, more context is needed to guide effective use.

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

Parameters2/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 for undocumented parameters. It mentions 'filtering and pagination,' which loosely relates to some parameters (e.g., state, page, per_page), but doesn't explain what specific filters exist (e.g., base, head, direction, sort) or their semantics. With 9 parameters and no schema descriptions, this minimal guidance is insufficient.

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 action ('List pull requests') and resource ('for a repository'), making the purpose immediately understandable. It also mentions additional capabilities ('with filtering and pagination'), which adds specificity. However, it doesn't explicitly differentiate this tool from sibling GitHub tools like github_get_pr_details or github_get_pr_status, which prevents a perfect score.

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. It doesn't mention sibling tools like github_get_pr_details (for specific PRs) or github_get_pr_status (for status checks), nor does it specify prerequisites or appropriate contexts. The agent must infer usage from the tool name 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

Related 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/MementoRC/mcp-git'

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