Skip to main content
Glama

get_pull_request_diff

Retrieve the changes in a pull request by specifying the repository owner, repository name, and pull request number. Utilize the MCP server for streamlined GitHub data access.

Instructions

Get the diff for a pull request

Input Schema

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

Implementation Reference

  • Core handler function that retrieves the pull request diff by making a GitHub API request with the 'application/vnd.github.diff' Accept header, returning 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 schemas defining the input parameters for the get_pull_request_diff tool: public schema without PAT and internal schema including 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:307-310 (registration)
    Tool registration in the listTools response, specifying name, description, and input schema.
    name: "get_pull_request_diff", description: "Get the diff for a pull request", inputSchema: zodToJsonSchema(pulls.GetPullRequestDiffSchema), },
  • Dispatcher in the main CallToolRequest handler switch statement that parses arguments, calls the core handler, and formats the response.
    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 }], }; }

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