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;

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