Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

get-pull-request-comments

Retrieve review comments from a GitHub pull request to analyze feedback and track code review discussions.

Instructions

Get the review comments on a pull request

Input Schema

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

Implementation Reference

  • The core handler function that validates input using Zod schema, calls the GitHub API (Octokit) to list review comments on a pull request, maps the response, and handles errors.
    export async function getPullRequestComments(args: unknown): Promise<any> {
      const { owner, repo, pull_number } = GetPullRequestCommentsSchema.parse(args);
      const github = getGitHubApi();
    
      return tryCatchAsync(async () => {
        const { data } = await github.getOctokit().pulls.listReviewComments({
          owner,
          repo,
          pull_number,
        });
    
        return data.map((comment) => ({
          id: comment.id,
          user: comment.user ? {
            login: comment.user.login,
            id: comment.user.id,
          } : null,
          body: comment.body,
          created_at: comment.created_at,
          updated_at: comment.updated_at,
          path: comment.path,
          position: comment.position,
          commit_id: comment.commit_id,
          url: comment.html_url,
        }));
      }, 'Failed to get pull request comments');
    }
  • Zod schema for input validation: requires owner, repo (from OwnerRepoSchema), and pull_number.
    export const GetPullRequestCommentsSchema = OwnerRepoSchema.extend({
      pull_number: z.number().int().positive(),
    });
  • src/server.ts:977-999 (registration)
    Tool registration in the MCP server's listTools response, including name, description, and JSON schema matching the Zod schema.
    {
      name: 'get-pull-request-comments',
      description: 'Get the review comments on a pull request',
      inputSchema: {
        type: 'object',
        properties: {
          owner: {
            type: 'string',
            description: 'Repository owner (username or organization)',
          },
          repo: {
            type: 'string',
            description: 'Repository name',
          },
          pull_number: {
            type: 'number',
            description: 'Pull request number',
          },
        },
        required: ['owner', 'repo', 'pull_number'],
        additionalProperties: false,
      },
    },
  • Switch case in the callTool handler that dispatches execution to the getPullRequestComments function.
    case 'get-pull-request-comments':
      result = await getPullRequestComments(parsedArgs);
      break;
  • Import of the input schema validator used in the handler.
    GetPullRequestCommentsSchema,

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

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