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
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner (username or organization) | |
| pull_number | Yes | Pull request number | |
| repo | Yes | Repository name |
Implementation Reference
- src/tools/pull-requests.ts:364-390 (handler)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'); }
- src/utils/validation.ts:174-176 (schema)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, }, },
- src/server.ts:1247-1249 (registration)Switch case in the callTool handler that dispatches execution to the getPullRequestComments function.case 'get-pull-request-comments': result = await getPullRequestComments(parsedArgs); break;
- src/tools/pull-requests.ts:13-13 (helper)Import of the input schema validator used in the handler.GetPullRequestCommentsSchema,