Skip to main content
Glama

get_pull_request_diff

Retrieve code changes from a GitHub pull request to review modifications before merging.

Instructions

Get the diff for a pull request

Input Schema

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

Implementation Reference

  • The main handler function that fetches the pull request diff using the GitHub API with a specific 'Accept: application/vnd.github.diff' header to retrieve the raw diff as a string.
    export async function getPullRequestDiff(
      github_pat: string,
      owner: string,
      repo: string,
      pullNumber: number
    ): Promise<string> {
      const response = await githubRequest(
        github_pat,
        `https://api.github.com/repos/${owner}/${repo}/pulls/${pullNumber}`,
        {
          headers: {
            "Accept": "application/vnd.github.diff"
          }
        }
      );
      
      // The response is already a string because the content type is not JSON
      return response as string;
    }
  • Zod input schemas for validating the tool arguments: public schema without PAT and internal schema including the GitHub PAT.
    export const GetPullRequestDiffSchema = z.object({
      owner: z.string().describe("Repository owner (username or organization)"),
      repo: z.string().describe("Repository name"),
      pull_number: z.number().describe("Pull request number")
    });
    
    export const _GetPullRequestDiffSchema = GetPullRequestDiffSchema.extend({
      github_pat: z.string().describe("GitHub Personal Access Token"),
    });
  • src/index.ts:306-310 (registration)
    Registration of the tool in the MCP server's listTools handler, specifying name, description, and input schema.
    {
      name: "get_pull_request_diff",
      description: "Get the diff for a pull request",
      inputSchema: zodToJsonSchema(pulls.GetPullRequestDiffSchema),
    },
  • src/index.ts:786-793 (registration)
    Dispatch logic in the MCP server's callToolRequest handler that parses arguments and calls the implementation function.
    case "get_pull_request_diff": {
      const args = pulls._GetPullRequestDiffSchema.parse(params.arguments);
      const { github_pat, owner, repo, pull_number } = args;
      const result = await pulls.getPullRequestDiff(github_pat, owner, repo, pull_number);
      return {
        content: [{ type: "text", text: result }],
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Get the diff' but doesn't specify what the diff includes (e.g., file changes, patch format), whether it requires authentication, rate limits, or error conditions. This leaves significant gaps for an agent to understand the tool's behavior.

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 sentence with no wasted words. It's front-loaded with the core purpose, making it easy to scan and understand quickly.

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?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the diff output looks like (e.g., raw patch text, structured data), potential side effects, or error handling. For a tool with 3 parameters and no structured behavioral hints, more context is needed.

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?

The input schema has 100% description coverage, with clear documentation for 'owner', 'repo', and 'pull_number'. The description adds no additional meaning beyond the schema, such as examples or constraints (e.g., pull_number must be an integer). Baseline 3 is appropriate since the schema does the heavy lifting.

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 'Get the diff for a pull request' clearly states the verb ('Get') and resource ('diff for a pull request'), making the purpose understandable. However, it doesn't differentiate from potential siblings like 'get_pull_request' or 'list_pull_requests', which might also retrieve pull request data but not specifically the diff.

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 prerequisites (e.g., needing a valid pull request number) or compare it to other tools in the sibling list (e.g., 'get_issue' for issue details vs. this for pull request diffs).

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

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