create-pull-request-review
Submit code reviews on GitHub pull requests by providing feedback, approving changes, requesting modifications, or adding comments to specific code lines.
Instructions
Create a review on a pull request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | The body text of the review | |
| comments | No | Comments to post as part of the review | |
| commit_id | No | The SHA of the commit that needs a review | |
| event | Yes | The review action to perform | |
| owner | Yes | Repository owner (username or organization) | |
| pull_number | Yes | Pull request number | |
| repo | Yes | Repository name |
Implementation Reference
- src/tools/pull-requests.ts:207-238 (handler)The handler function that implements the core logic of the 'create-pull-request-review' tool. It validates input using Zod schema, calls the GitHub API to create a review, and returns the review details./** * Create a review on a pull request */ export async function createPullRequestReview(args: unknown): Promise<any> { const { owner, repo, pull_number, body, event, commit_id, comments } = CreatePullRequestReviewSchema.parse(args); const github = getGitHubApi(); return tryCatchAsync(async () => { const { data } = await github.getOctokit().pulls.createReview({ owner, repo, pull_number, body, event, commit_id, comments, }); return { id: data.id, user: data.user ? { login: data.user.login, id: data.user.id, } : null, body: data.body, state: data.state, commit_id: data.commit_id, submitted_at: data.submitted_at, url: data.html_url, }; }, 'Failed to create pull request review'); }
- src/utils/validation.ts:138-152 (schema)Zod schema definition for validating the input parameters of the create-pull-request-review tool.export const CreatePullRequestReviewSchema = OwnerRepoSchema.extend({ pull_number: z.number().int().positive(), body: z.string().min(1, 'Review body is required'), event: z.enum(['APPROVE', 'REQUEST_CHANGES', 'COMMENT']), commit_id: z.string().optional(), comments: z .array( z.object({ path: z.string().min(1, 'File path is required'), position: z.number().int().positive(), body: z.string().min(1, 'Comment body is required'), }) ) .optional(), });
- src/server.ts:809-866 (registration)Tool registration in the MCP server's listTools handler, providing the tool name, description, and input schema for client discovery.{ name: 'create-pull-request-review', description: 'Create a review 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', }, commit_id: { type: 'string', description: 'The SHA of the commit that needs a review', }, body: { type: 'string', description: 'The body text of the review', }, event: { type: 'string', enum: ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], description: 'The review action to perform', }, comments: { type: 'array', items: { type: 'object', properties: { path: { type: 'string', description: 'The relative path to the file being commented on', }, position: { type: 'number', description: 'The position in the diff where you want to add a review comment', }, body: { type: 'string', description: 'Text of the review comment', }, }, required: ['path', 'position', 'body'], additionalProperties: false, }, description: 'Comments to post as part of the review', }, }, required: ['owner', 'repo', 'pull_number', 'body', 'event'], additionalProperties: false, },
- src/server.ts:1235-1237 (registration)Switch case in the callTool handler that routes execution to the createPullRequestReview function.case 'create-pull-request-review': result = await createPullRequestReview(parsedArgs); break;