Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

list-pull-requests

Retrieve and filter pull requests from GitHub repositories by state, branch, or sorting criteria to monitor code review activity and manage contributions.

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

  • The handler function for 'list-pull-requests' tool. Validates input with ListPullRequestsSchema, fetches pull requests via GitHub API, and returns formatted list.
    export async function listPullRequests(args: unknown): Promise<any> {
      const { owner, repo, state, head, base, sort, direction, per_page, page } = ListPullRequestsSchema.parse(args);
      const github = getGitHubApi();
    
      return tryCatchAsync(async () => {
        const { data } = await github.getOctokit().pulls.list({
          owner,
          repo,
          state,
          head,
          base,
          sort,
          direction,
          per_page,
          page,
        });
    
        return data.map((pr) => ({
          id: pr.id,
          number: pr.number,
          title: pr.title,
          state: pr.state,
          locked: pr.locked,
          user: pr.user ? {
            login: pr.user.login,
            id: pr.user.id,
            type: pr.user.type,
          } : null,
          created_at: pr.created_at,
          updated_at: pr.updated_at,
          closed_at: pr.closed_at,
          merged_at: pr.merged_at,
          merge_commit_sha: pr.merge_commit_sha,
          draft: pr.draft,
          head: {
            ref: pr.head.ref,
            sha: pr.head.sha,
            repo: pr.head.repo ? {
              name: pr.head.repo.name,
              full_name: pr.head.repo.full_name,
              owner: {
                login: pr.head.repo.owner.login,
              },
            } : null,
          },
          base: {
            ref: pr.base.ref,
            sha: pr.base.sha,
            repo: pr.base.repo ? {
              name: pr.base.repo.name,
              full_name: pr.base.repo.full_name,
              owner: {
                login: pr.base.repo.owner.login,
              },
            } : null,
          },
          body: pr.body,
          url: pr.html_url,
        }));
      }, 'Failed to list pull requests');
    }
  • Zod schema used for input validation in the listPullRequests handler.
    export const ListPullRequestsSchema = OwnerRepoSchema.extend({
      state: z.enum(['open', 'closed', 'all']).optional(),
      head: z.string().optional(),
      base: z.string().optional(),
      sort: z.enum(['created', 'updated', 'popularity', 'long-running']).optional(),
      direction: z.enum(['asc', 'desc']).optional(),
      per_page: z.number().optional(),
      page: z.number().optional(),
    });
  • src/server.ts:693-742 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining name, description, and inputSchema.
    {
      name: 'list-pull-requests',
      description: 'List and filter repository pull requests',
      inputSchema: {
        type: 'object',
        properties: {
          owner: {
            type: 'string',
            description: 'Repository owner (username or organization)',
          },
          repo: {
            type: 'string',
            description: 'Repository name',
          },
          state: {
            type: 'string',
            enum: ['open', 'closed', 'all'],
            description: 'State of the pull requests to return',
          },
          head: {
            type: 'string',
            description: 'Filter by head user or head organization and branch name',
          },
          base: {
            type: 'string',
            description: 'Filter by base branch name',
          },
          sort: {
            type: 'string',
            enum: ['created', 'updated', 'popularity', 'long-running'],
            description: 'What to sort results by',
          },
          direction: {
            type: 'string',
            enum: ['asc', 'desc'],
            description: 'The direction of the sort',
          },
          per_page: {
            type: 'number',
            description: 'Results per page (max 100)',
          },
          page: {
            type: 'number',
            description: 'Page number of the results',
          },
        },
        required: ['owner', 'repo'],
        additionalProperties: false,
      },
    },
  • Dispatch case in CallToolRequestSchema handler that invokes the listPullRequests function.
    case 'list-pull-requests':
      result = await listPullRequests(parsedArgs);
      break;
Behavior2/5

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

With no annotations provided, the description carries full burden but reveals almost nothing about behavior. It doesn't disclose whether this is a read-only operation, what authentication is needed, whether it supports pagination (implied by parameters but not stated), rate limits, or what the return format looks like. 'List and filter' implies reading, but lacks crucial operational details.

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 phrase that front-loads the core functionality. Every word earns its place with zero waste or redundancy, making it immediately scannable and understandable.

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?

For a tool with 9 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the relationship between parameters, what the output contains, pagination behavior, or error conditions. The agent would need to infer too much from the parameter schema alone.

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 all parameters are documented in the schema. The description adds no additional parameter semantics beyond the basic 'filter' hint, which is already covered by the schema's detailed parameter descriptions. This meets the baseline for high schema coverage.

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 'List and filter repository pull requests' clearly states the verb ('list and filter') and resource ('repository pull requests'), making the purpose immediately understandable. It distinguishes itself from siblings like 'get-pull-request' (singular) and 'list-issues', but doesn't explicitly differentiate from other list/filter tools like 'list-issues' beyond the resource type.

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 when to choose this over 'search-issues' (which might include PRs) or 'get-pull-request' (for a specific PR), nor does it specify prerequisites like authentication or repository access requirements.

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

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