GitHub Pull Requests & Code Review
Lets an agent review pull requests on GitHub: read the PR, its changed files with per-file diffs, commits and existing discussion, then post a single review with inline comments. It can also open and update pull requests, request reviewers and merge once a person approves. Curated from GitHub's official OpenAPI specification.
Connect this API to an AI agent Browse all specs
What you can do with GitHub Pull Requests & Code Review via MCP
Every endpoint below becomes a governed tool your AI agent (Claude, ChatGPT, or a customer-facing VX agent) can call — with scoped permissions, sandbox testing, and audit logs.
| Method | Path | Operation | Description |
|---|---|---|---|
| GET | /repos/{owner}/{repo}/pulls |
listPullRequests | List pull requests in a repository (filter by state, head, base) |
| POST | /repos/{owner}/{repo}/pulls |
createPullRequest | Open a new pull request from one branch into another |
| GET | /repos/{owner}/{repo}/pulls/{pull_number} |
getPullRequest | Get one pull request with its title, description, branches and head SHA |
| PATCH | /repos/{owner}/{repo}/pulls/{pull_number} |
updatePullRequest | Change a pull request's title, description, base branch or state |
| GET | /repos/{owner}/{repo}/pulls/{pull_number}/files |
listPullRequestFiles | List the files changed in a pull request with each file's diff (patch) |
| GET | /repos/{owner}/{repo}/pulls/{pull_number}/commits |
listPullRequestCommits | List the commits in a pull request |
| GET | /repos/{owner}/{repo}/compare/{basehead} |
compareCommits | Compare two branches or commits and see the changed files |
| GET | /repos/{owner}/{repo}/pulls/{pull_number}/reviews |
listPullRequestReviews | List the reviews already submitted on a pull request |
| POST | /repos/{owner}/{repo}/pulls/{pull_number}/reviews |
createPullRequestReview | Submit a review (comment, approve or request changes) with inline comments |
| GET | /repos/{owner}/{repo}/pulls/{pull_number}/comments |
listPullRequestReviewComments | List inline review comments on a pull request's code |
| POST | /repos/{owner}/{repo}/pulls/{pull_number}/comments |
createPullRequestReviewComment | Add a single inline comment on a line of a pull request's diff |
| GET | /repos/{owner}/{repo}/issues/{issue_number}/comments |
listIssueComments | List conversation comments on a pull request (use the PR number) |
| POST | /repos/{owner}/{repo}/issues/{issue_number}/comments |
createIssueComment | Post a general comment in a pull request's conversation |
| POST | /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers |
requestPullRequestReviewers | Ask people or teams to review a pull request |
| PUT | /repos/{owner}/{repo}/pulls/{pull_number}/merge |
mergePullRequest | Merge a pull request (only after the user confirms) |
Authentication
githubToken
Bearer token — sent as Authorization: Bearer <token>
GitHub fine-grained personal access token (or a GitHub App installation token) sent as Authorization: Bearer <token>.
How to get a credential
- In GitHub open Settings > Developer settings > Personal access tokens > Fine-grained tokens and click Generate new token.
- Pick the resource owner (your user or organization) and set an expiry.
- Under Repository access choose Only select repositories and pick the repositories the agent may review.
- Under Repository permissions set Pull requests: Read and write, Contents: Read-only, Issues: Read and write (Metadata: Read-only is added automatically).
- Generate the token and copy it (it starts with
github_pat_). Organization-owned repositories may need an owner to approve the token.
Permissions used
| Permission | Operations |
|---|---|
| Metadata: read | all read calls on the repository |
| Pull requests: read | listPullRequests, getPullRequest, listPullRequestFiles, listPullRequestCommits, listPullRequestReviews, listPullRequestReviewComments |
| Contents: read | compareCommits, listPullRequestFiles |
| Pull requests: write | createPullRequestReview, createPullRequestReviewComment, createPullRequest, updatePullRequest, requestPullRequestReviewers |
| Contents: write + Pull requests: write | mergePullRequest |
| Issues: read / write | listIssueComments / createIssueComment (PR conversation comments) |
Common errors
- 401 Bad credentials: the token is wrong, expired or revoked; generate a new one.
- 403 Resource not accessible by personal access token: a permission above is missing or the repository is not selected on the token; edit the token. A 403 with
X-RateLimit-Remaining: 0means the rate limit (5,000 requests/hour) is used up; wait untilX-RateLimit-Reset. - 404 Not Found: the repository is private and the token cannot see it, or owner/repo/number is wrong.
- 422 Validation failed: the review comment points at a line that is not in the diff, or the PR is not mergeable; re-read the files and retry with a valid
path/line.
Store the token as a VX Agents credential for this connector; never paste it into chat.
Usage guide
Setup
- Add a GitHub fine-grained token as the credential (Pull requests read/write, Contents read, Issues read/write on the repositories to review).
- Preset
ownerandrepoif the agent always works on one repository.X-GitHub-Api-Versionis pinned to2022-11-28.
Review a pull request
getPullRequest— read title, description, base/head branches andhead.sha.listPullRequestFileswithper_page=100; keep calling withpage=2,3…until fewer than 100 files come back. Each file'spatchis the diff to review (very large files have no patch).- Optional context:
listPullRequestCommits, orcompareCommitswithbasehead=base...head. - Read what was already said:
listPullRequestReviews,listPullRequestReviewComments,listIssueComments(use the PR number asissue_number). Do not repeat points already raised. - Post ONE review with
createPullRequestReview:commit_id= head SHA,body= summary,event=COMMENT, andcomments= [{path,line,side:RIGHT,body}].lineis the line number in the new version of the file and must be inside the diff. - Use
event=APPROVEorREQUEST_CHANGESonly after the user confirms.
Other workflows
- Open a PR:
createPullRequestwithhead(branch with changes,owner:branchfor forks),base,title,body. Pushing the branch itself is done with the "GitHub Branches & File Commits" spec. requestPullRequestReviewerswithreviewers(usernames) orteam_reviewers(team slugs).updatePullRequestto edit title/body or close (state: closed).mergePullRequest(merge_method: merge, squash or rebase) — ALWAYS ask the user first and passsha= head SHA so a newer push is not merged by mistake.
Good to know
- Confirm with the user before any write that posts comments, approves, requests changes, opens/closes or merges a PR.
createPullRequestReviewCommentposts a single inline comment immediately; prefer one review with many comments.pull_numberandissue_numberare the same PR number shown in the URL.- Timestamps are ISO 8601 UTC. Rate limit is 5,000 requests/hour per token; 422 usually means a comment line is outside the diff.
How to use this spec
- Create a free VX Agents account (sandbox tools included).
- Open the marketplace and connect “GitHub Pull Requests & Code Review” to an agent.
- Expose it as an MCP server for Claude/ChatGPT, or chat with it directly.