get_pull_request_status
Determine the status (open, closed, merged) of a pull request by providing the repository owner, name, and pull number.
Instructions
Get the status of a specific pull request.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner | |
| repo | Yes | Repository name | |
| pullNumber | Yes | Pull request number |
Implementation Reference
- src/tools/pullrequests.ts:377-473 (handler)The main handler function for the 'get_pull_request_status' tool. It fetches the pull request via octokit to get the head SHA, then calls getCombinedStatusForRef to retrieve the combined status. It formats the result as markdown with status check groups (failed, error, pending, passed).
server.tool( "get_pull_request_status", "Get the status of a specific pull request.", { owner: z.string().describe("Repository owner"), repo: z.string().describe("Repository name"), pullNumber: z.number().describe("Pull request number"), }, async ({ owner, repo, pullNumber }) => { try { // Get the PR to find the head SHA const prResp = await octokit.rest.pulls.get({ owner, repo, pull_number: pullNumber, }) const sha = prResp.data.head.sha const statusResp = await octokit.rest.repos.getCombinedStatusForRef({ owner, repo, ref: sha, }) const status = statusResp.data // Format as clean markdown let markdown = `# Pull Request #${pullNumber} Status\n\n` markdown += `**Overall State:** ${status.state}\n` markdown += `**SHA:** ${status.sha.substring(0, 7)}\n` markdown += `**Total Checks:** ${status.total_count}\n\n` if (status.statuses && status.statuses.length > 0) { markdown += `## Status Checks\n\n` // Group statuses by state const grouped = { success: status.statuses.filter(s => s.state === "success"), failure: status.statuses.filter(s => s.state === "failure"), error: status.statuses.filter(s => s.state === "error"), pending: status.statuses.filter(s => s.state === "pending"), } // Show failures and errors first if (grouped.failure.length > 0) { markdown += `### Failed\n\n` grouped.failure.forEach(check => { markdown += `- **${check.context}**: ${check.description || "No description"}\n` if (check.target_url) { markdown += ` - [View Details](${check.target_url})\n` } }) markdown += `\n` } if (grouped.error.length > 0) { markdown += `### Errors\n\n` grouped.error.forEach(check => { markdown += `- **${check.context}**: ${check.description || "No description"}\n` if (check.target_url) { markdown += ` - [View Details](${check.target_url})\n` } }) markdown += `\n` } if (grouped.pending.length > 0) { markdown += `### Pending\n\n` grouped.pending.forEach(check => { markdown += `- **${check.context}**: ${check.description || "No description"}\n` if (check.target_url) { markdown += ` - [View Details](${check.target_url})\n` } }) markdown += `\n` } if (grouped.success.length > 0) { markdown += `### Passed\n\n` grouped.success.forEach(check => { markdown += `- **${check.context}**: ${check.description || "No description"}\n` }) markdown += `\n` } } else { markdown += `*No status checks found*\n` } return { content: [{ type: "text", text: markdown }], } } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], } } }, ) - src/tools/pullrequests.ts:380-384 (schema)Input schema for the tool, defining required parameters: owner (string), repo (string), and pullNumber (number) using Zod validation.
{ owner: z.string().describe("Repository owner"), repo: z.string().describe("Repository name"), pullNumber: z.number().describe("Pull request number"), }, - src/tools/pullrequests.ts:377-378 (registration)Registration of the tool via server.tool() with the name 'get_pull_request_status' and description 'Get the status of a specific pull request.'
server.tool( "get_pull_request_status", - src/index.ts:18-18 (registration)The call to registerPullRequestTools(server, octokit) which registers all pull request tools including get_pull_request_status.
registerPullRequestTools(server, octokit)