Skip to main content
Glama

list_pull_requests

Retrieve and filter pull requests from a GitHub repository by owner, repo, state, head, base, sort, direction, and pagination for streamlined PR management.

Instructions

List and filter repository pull requests

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baseNoFilter by base branch name
directionNoThe direction of the sort
headNoFilter by head user or head organization and branch name
ownerYesRepository owner (username or organization)
pageNoPage number of the results
per_pageNoResults per page (max 100)
repoYesRepository name
sortNoWhat to sort results by
stateNoState of the pull requests to return

Implementation Reference

  • Core handler function that constructs the GitHub API URL for listing pull requests with optional filters and fetches/parses the response.
    export async function listPullRequests(
      owner: string,
      repo: string,
      options: Omit<z.infer<typeof ListPullRequestsSchema>, 'owner' | 'repo'>
    ): Promise<z.infer<typeof GitHubPullRequestSchema>[]> {
      const url = new URL(`https://api.github.com/repos/${owner}/${repo}/pulls`);
      
      if (options.state) url.searchParams.append('state', options.state);
      if (options.head) url.searchParams.append('head', options.head);
      if (options.base) url.searchParams.append('base', options.base);
      if (options.sort) url.searchParams.append('sort', options.sort);
      if (options.direction) url.searchParams.append('direction', options.direction);
      if (options.per_page) url.searchParams.append('per_page', options.per_page.toString());
      if (options.page) url.searchParams.append('page', options.page.toString());
    
      const response = await githubRequest(url.toString());
      return z.array(GitHubPullRequestSchema).parse(response);
    }
  • Zod input schema defining parameters for the list_pull_requests tool, including owner, repo, and optional filters.
    export const ListPullRequestsSchema = z.object({
      owner: z.string().describe("Repository owner (username or organization)"),
      repo: z.string().describe("Repository name"),
      state: z.enum(['open', 'closed', 'all']).optional().describe("State of the pull requests to return"),
      head: z.string().optional().describe("Filter by head user or head organization and branch name"),
      base: z.string().optional().describe("Filter by base branch name"),
      sort: z.enum(['created', 'updated', 'popularity', 'long-running']).optional().describe("What to sort results by"),
      direction: z.enum(['asc', 'desc']).optional().describe("The direction of the sort"),
      per_page: z.number().optional().describe("Results per page (max 100)"),
      page: z.number().optional().describe("Page number of the results")
    });
  • index.ts:160-164 (registration)
    Registration of the list_pull_requests tool in the ListToolsRequest handler, specifying name, description, and input schema.
    {
      name: "list_pull_requests",
      description: "List and filter repository pull requests",
      inputSchema: zodToJsonSchema(pulls.ListPullRequestsSchema)
    },
  • Dispatcher handler in the main CallToolRequest switch that parses arguments, calls the listPullRequests function, and formats the response.
    case "list_pull_requests": {
      const args = pulls.ListPullRequestsSchema.parse(request.params.arguments);
      const { owner, repo, ...options } = args;
      const pullRequests = await pulls.listPullRequests(owner, repo, options);
      return {
        content: [{ type: "text", text: JSON.stringify(pullRequests, null, 2) }],
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'list and filter' but doesn't describe pagination behavior (implied by page/per_page parameters), rate limits, authentication requirements, whether it's read-only, or what the return format looks like. For a tool with 9 parameters and no output schema, this is insufficient.

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 communicates the core functionality without waste. It's appropriately sized and front-loaded with the essential information.

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 inadequate. It doesn't explain the return format, pagination behavior, authentication needs, or how it differs from similar tools. For a list/filter operation with rich parameters, more context is needed.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all 9 parameters thoroughly with descriptions and enums. The description adds no additional parameter information beyond what's in the schema, so it meets the baseline but doesn't provide extra value.

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 verb 'list and filter' and the resource 'repository pull requests', making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_pull_request' (singular) or 'list_issues', which would require explicit comparison to achieve 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 'get_pull_request' (for single PRs), 'list_issues' (for issues instead of PRs), or 'search_issues' (which might include PRs). There's no context about prerequisites or when this tool is preferred.

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/tuanle96/mcp-github'

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