Skip to main content
Glama

get_pull_request

Retrieve details of a specific pull request in a GitHub repository by providing the repository owner, name, and pull request number.

Instructions

Get details of a specific pull request in a GitHub repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner
repoYesRepository name
pullNumberYesPull request number

Implementation Reference

  • Handler function for 'get_pull_request' tool. Calls octokit.rest.pulls.get() and formats PR details including state, author, branches, dates, commits, files, assignees, reviewers, labels, and body as markdown.
    	async ({ owner, repo, pullNumber }) => {
    		try {
    			const response = await octokit.rest.pulls.get({
    				owner,
    				repo,
    				pull_number: pullNumber,
    			})
    			const pr = response.data
    			let text = `**PR #${pr.number}: ${pr.title}**\n`
    			text += `State: ${pr.state}${pr.draft ? " (draft)" : ""}${pr.merged ? " (merged)" : ""}\n`
    			text += `URL: ${pr.html_url}\n`
    			text += `Author: ${pr.user?.login || "unknown"}\n`
    			text += `Branch: ${pr.head.label} -> ${pr.base.label}\n`
    			text += `Created: ${pr.created_at}\n`
    			text += `Updated: ${pr.updated_at}\n`
    			if (pr.merged_at) text += `Merged: ${pr.merged_at}\n`
    			text += `Commits: ${pr.commits} | Changed files: ${pr.changed_files} | +${pr.additions} -${pr.deletions}\n`
    			if (pr.assignees && pr.assignees.length > 0) text += `Assignees: ${pr.assignees.map(a => a.login).join(", ")}\n`
    			if (pr.requested_reviewers && pr.requested_reviewers.length > 0) text += `Reviewers: ${pr.requested_reviewers.map((r: any) => r.login).join(", ")}\n`
    			if (pr.labels && pr.labels.length > 0) text += `Labels: ${pr.labels.map(l => l.name).join(", ")}\n`
    			if (pr.body) text += `\n---\n${pr.body}\n`
    			return {
    				content: [{ type: "text", text }],
    			}
    		} catch (e: any) {
    			return {
    				content: [{ type: "text", text: `Error: ${e.message}` }],
    			}
    		}
    	},
    )
  • Zod schema definitions for 'get_pull_request' inputs: owner (string), repo (string), and pullNumber (number).
    {
    	owner: z.string().describe("Repository owner"),
    	repo: z.string().describe("Repository name"),
    	pullNumber: z.number().describe("Pull request number"),
    },
  • Registration of the 'get_pull_request' tool via server.tool() with name, description, input schema, and handler.
    server.tool(
    	"get_pull_request",
    	"Get details of a specific pull request in a GitHub repository.",
    	{
    		owner: z.string().describe("Repository owner"),
    		repo: z.string().describe("Repository name"),
    		pullNumber: z.number().describe("Pull request number"),
    	},
    	async ({ owner, repo, pullNumber }) => {
    		try {
    			const response = await octokit.rest.pulls.get({
    				owner,
    				repo,
    				pull_number: pullNumber,
    			})
    			const pr = response.data
    			let text = `**PR #${pr.number}: ${pr.title}**\n`
    			text += `State: ${pr.state}${pr.draft ? " (draft)" : ""}${pr.merged ? " (merged)" : ""}\n`
    			text += `URL: ${pr.html_url}\n`
    			text += `Author: ${pr.user?.login || "unknown"}\n`
    			text += `Branch: ${pr.head.label} -> ${pr.base.label}\n`
    			text += `Created: ${pr.created_at}\n`
    			text += `Updated: ${pr.updated_at}\n`
    			if (pr.merged_at) text += `Merged: ${pr.merged_at}\n`
    			text += `Commits: ${pr.commits} | Changed files: ${pr.changed_files} | +${pr.additions} -${pr.deletions}\n`
    			if (pr.assignees && pr.assignees.length > 0) text += `Assignees: ${pr.assignees.map(a => a.login).join(", ")}\n`
    			if (pr.requested_reviewers && pr.requested_reviewers.length > 0) text += `Reviewers: ${pr.requested_reviewers.map((r: any) => r.login).join(", ")}\n`
    			if (pr.labels && pr.labels.length > 0) text += `Labels: ${pr.labels.map(l => l.name).join(", ")}\n`
    			if (pr.body) text += `\n---\n${pr.body}\n`
    			return {
    				content: [{ type: "text", text }],
    			}
    		} catch (e: any) {
    			return {
    				content: [{ type: "text", text: `Error: ${e.message}` }],
    			}
    		}
    	},
    )
  • src/index.ts:18-19 (registration)
    Registration call: registerPullRequestTools(server, octokit) in the main setup function.
    registerPullRequestTools(server, octokit)
    registerRepositoryResource(server, octokit)
  • Import statement for registerPullRequestTools from './tools/pullrequests.js'.
    import { registerPullRequestTools } from "./tools/pullrequests.js"
    import { registerRepositoryTools } from "./tools/repositories.js"
    import { registerSearchTools } from "./tools/search.js"
    import { registerRepositoryResource } from "./resources/repository_resource.js"
Behavior2/5

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

No annotations are present, so the description must disclose behavioral traits. It only says 'Get details' without mentioning read-only nature, authentication needs, rate limits, or error handling. The disclosure is minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence without wasted words. It is appropriately sized for a simple get-tool, though it could briefly hint at return values.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (3 params, no nested objects) and complete schema coverage, the description is adequate. However, lacking an output schema, it does not explain what 'details' means, which could lead to ambiguity.

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 coverage is 100%, meaning each parameter has a description. The tool description adds no additional meaning beyond what the schema already provides, so baseline score of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (Get) and the specific resource (details of a specific pull request), which distinguishes it from sibling tools like list_pull_requests (list) and get_pull_request_comments (different resource).

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?

No guidance is provided on when to use this tool versus alternatives (e.g., get_pull_request_comments, list_pull_requests). The description does not include prerequisites, context, or exclusions.

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

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