Skip to main content
Glama
gourav221b

GitHub PR MCP Server

by gourav221b

get-pull-request-data

Extract comprehensive GitHub Pull Request details, including files, diffs, comments, and reviews, for efficient analysis and review processes.

Instructions

Get detailed information about a GitHub Pull Request including files, diff, comments, and reviews

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesGitHub repository owner
pullNumberYesPull request number
repoYesGitHub repository name
tokenNoGitHub personal access token (optional)

Implementation Reference

  • The asynchronous handler function for the 'get-pull-request-data' tool. It initializes the Octokit client, fetches PR data using the helper function, and returns formatted JSON or error response.
    async ({ owner, repo, pullNumber, token }) => {
        try {
            // Initialize Octokit with token if provided
            const octokit = new Octokit({
                auth: token,
                baseUrl: GITHUB_API_BASE,
            });
    
            // Get all PR information
            const prData = await getAllPullRequestInfo(octokit, owner, repo, pullNumber);
    
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify(prData, null, 2)
                    }
                ]
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: "text",
                        text: `Error: ${error instanceof Error ? error.message : "An unknown error occurred"}`
                    }
                ],
                isError: true
            };
        }
    }
  • Zod input schema defining the parameters for the 'get-pull-request-data' tool: owner, repo, pullNumber, and optional token.
    {
        owner: z.string().describe("GitHub repository owner"),
        repo: z.string().describe("GitHub repository name"),
        pullNumber: z.number().describe("Pull request number"),
        token: z.string().optional().describe("GitHub personal access token (optional)"),
    },
  • src/index.ts:17-57 (registration)
    Registration of the 'get-pull-request-data' tool using server.tool(), including name, description, input schema, and handler function.
    server.tool(
        "get-pull-request-data",
        "Get detailed information about a GitHub Pull Request including files, diff, comments, and reviews",
        {
            owner: z.string().describe("GitHub repository owner"),
            repo: z.string().describe("GitHub repository name"),
            pullNumber: z.number().describe("Pull request number"),
            token: z.string().optional().describe("GitHub personal access token (optional)"),
        },
        async ({ owner, repo, pullNumber, token }) => {
            try {
                // Initialize Octokit with token if provided
                const octokit = new Octokit({
                    auth: token,
                    baseUrl: GITHUB_API_BASE,
                });
    
                // Get all PR information
                const prData = await getAllPullRequestInfo(octokit, owner, repo, pullNumber);
    
                return {
                    content: [
                        {
                            type: "text",
                            text: JSON.stringify(prData, null, 2)
                        }
                    ]
                };
            } catch (error) {
                return {
                    content: [
                        {
                            type: "text",
                            text: `Error: ${error instanceof Error ? error.message : "An unknown error occurred"}`
                        }
                    ],
                    isError: true
                };
            }
        }
    );
  • Helper function that fetches comprehensive Pull Request data by calling sub-helpers for details, diff, comments, and reviews in parallel.
    export async function getAllPullRequestInfo(
        octokit: Octokit,
        owner: string,
        repo: string,
        pullNumber: number
    ): Promise<{
        details: PullRequestDetails;
        diff: string;
        comments: any[];
    
    }> {
        const [details, diff, comments,] = await Promise.all([
            getPullRequestDetails(octokit, owner, repo, pullNumber),
    
            getPullRequestDiff(octokit, owner, repo, pullNumber),
            getPullRequestComments(octokit, owner, repo, pullNumber),
            getPullRequestReviews(octokit, owner, repo, pullNumber),
        ]);
    
        return {
            details,
            diff,
            comments,
    
        };
    }
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 mentions what data is retrieved but fails to describe critical behaviors such as authentication requirements (though the token parameter is optional in the schema), rate limits, error handling, or response format. For a tool with no annotations, this leaves the agent with insufficient operational context.

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 that front-loads the core action and details without waste. Every word earns its place by specifying the resource and the scope of information retrieved, making it highly concise and well-structured.

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 complexity of retrieving detailed PR data and the lack of annotations and output schema, the description is incomplete. It does not cover behavioral aspects like authentication, rate limits, or response structure, which are crucial for an agent to use the tool effectively. The description alone is insufficient for safe and informed tool invocation.

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 schema description coverage is 100%, so the schema already documents all parameters (owner, repo, pullNumber, token). The description does not add any meaning beyond what the schema provides, such as explaining parameter interactions or constraints. Baseline 3 is appropriate as the schema handles parameter documentation adequately.

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 clearly states the verb ('Get') and resource ('detailed information about a GitHub Pull Request'), and specifies what information is included ('files, diff, comments, and reviews'). It distinguishes the scope of data retrieved, though without sibling tools, differentiation isn't applicable. The purpose is specific and actionable.

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, prerequisites, or context for invocation. It lacks any mention of when-not-to-use scenarios or comparisons to other tools, which is a significant gap despite the absence of sibling tools. Usage is implied by the name and description but not explicitly stated.

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

Related 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/gourav221b/Github-PR-MCP-server'

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