Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

get-pull-request-status

Retrieve the combined status of all checks for a GitHub pull request to verify if it's ready for merge by providing repository owner, name, and PR number.

Instructions

Get the combined status of all status checks for a pull request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner (username or organization)
pull_numberYesPull request number
repoYesRepository name

Implementation Reference

  • The primary handler function for the 'get-pull-request-status' tool. It validates input using GetPullRequestStatusSchema, fetches the PR head SHA, and retrieves combined status checks from GitHub API.
    export async function getPullRequestStatus(args: unknown): Promise<any> {
      const { owner, repo, pull_number } = GetPullRequestStatusSchema.parse(args);
      const github = getGitHubApi();
    
      return tryCatchAsync(async () => {
        // First get the pull request to get the head SHA
        const { data: pr } = await github.getOctokit().pulls.get({
          owner,
          repo,
          pull_number,
        });
    
        // Then get the combined status for the head SHA
        const { data } = await github.getOctokit().repos.getCombinedStatusForRef({
          owner,
          repo,
          ref: pr.head.sha,
        });
    
        return {
          state: data.state,
          statuses: data.statuses.map((status) => ({
            context: status.context,
            state: status.state,
            description: status.description,
            target_url: status.target_url,
            created_at: status.created_at,
            updated_at: status.updated_at,
          })),
          sha: data.sha,
          total_count: data.total_count,
          repository: {
            name: data.repository.name,
            full_name: data.repository.full_name,
            owner: {
              login: data.repository.owner.login,
            },
          },
        };
      }, 'Failed to get pull request status');
    }
  • Zod schema for runtime input validation of the getPullRequestStatus tool parameters.
    export const GetPullRequestStatusSchema = OwnerRepoSchema.extend({
      pull_number: z.number().int().positive(),
    });
  • src/server.ts:927-949 (registration)
    Tool registration in the ListTools response, including name, description, and MCP input schema.
    {
      name: 'get-pull-request-status',
      description: 'Get the combined status of all status checks for a pull request',
      inputSchema: {
        type: 'object',
        properties: {
          owner: {
            type: 'string',
            description: 'Repository owner (username or organization)',
          },
          repo: {
            type: 'string',
            description: 'Repository name',
          },
          pull_number: {
            type: 'number',
            description: 'Pull request number',
          },
        },
        required: ['owner', 'repo', 'pull_number'],
        additionalProperties: false,
      },
    },
  • Dispatcher case in the CallToolRequestHandler switch statement that invokes the getPullRequestStatus handler.
    case 'get-pull-request-status':
      result = await getPullRequestStatus(parsedArgs);
      break;
  • src/server.ts:48-52 (registration)
    Import statement for the getPullRequestStatus function from the pull-requests module.
      getPullRequestStatus,
      updatePullRequestBranch,
      getPullRequestComments,
      getPullRequestReviews,
    } from './tools/pull-requests.js';

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