github-pr-review-mcp
A local MCP server that reads GitHub pull request diffs and coding standards, then posts inline review comments and full reviews to PRs via any MCP client.
README
github-pr-review-mcp
A local MCP server for reviewing GitHub pull requests: it reads PR diffs, reads your coding standards, and posts inline review comments / a full review back to the PR — all driven by whatever MCP client you connect it to (e.g. Claude Desktop or Claude Code).
Scope is intentionally narrow: this server can only read PR/repo data and post PR review comments/reviews. It cannot edit files, push commits, merge, delete, or manage anything else in your GitHub account.
Tools
| Tool | Read/Write | Description |
|---|---|---|
github_whoami |
read | Verify the token works, show the authenticated user |
github_list_pull_requests |
read | List open/closed/all PRs on a repo |
github_get_pull_request |
read | Full PR metadata, including head_sha |
github_get_pull_request_diff |
read | Full unified diff for a PR |
github_get_pull_request_files |
read | Per-file patches + add/delete counts |
github_get_review_standards |
read | Your local STANDARDS.md and/or a standards file from inside the target repo |
github_list_review_comments |
read | Existing inline comments already on the PR |
github_post_review_comment |
write | Post one standalone inline comment |
github_submit_pr_review |
write | Submit a full review: summary + verdict (COMMENT/APPROVE/REQUEST_CHANGES) + inline comments |
1. Create a GitHub token
- GitHub → Settings → Developer settings → Fine-grained personal access tokens → Generate new token.
- Resource owner: your account (or the org that owns the repos you'll review).
- Repository access: select the specific repos you want this server to touch.
- Permissions → Pull requests: Read and write. (Also grant Contents: Read-only if you want
github_get_review_standardsto fetch a standards file from inside the repo.) - Generate and copy the token (starts with
github_pat_orghp_).
2. Install dependencies
cd github-pr-review-mcp
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
3. Configure
Edit STANDARDS.md in this folder to reflect the standards you actually want
enforced (it ships with a generic starter template — trim/expand it).
Set your token as an environment variable, or wire it into your MCP client config directly (see step 4) — either works, you don't need both.
export GITHUB_TOKEN=github_pat_xxxxxxxxxxxx
4. Register with your MCP client
Claude Desktop — edit claude_desktop_config.json:
{
"mcpServers": {
"github-pr-review": {
"command": "/absolute/path/to/github-pr-review-mcp/.venv/bin/python",
"args": ["/absolute/path/to/github-pr-review-mcp/server.py"],
"env": {
"GITHUB_TOKEN": "github_pat_xxxxxxxxxxxx"
}
}
}
}
Claude Code — from the project directory:
claude mcp add github-pr-review \
--env GITHUB_TOKEN=github_pat_xxxxxxxxxxxx \
-- /absolute/path/to/github-pr-review-mcp/.venv/bin/python /absolute/path/to/github-pr-review-mcp/server.py
Restart the client after editing config. Then ask it to run github_whoami
to confirm the connection works.
5. Typical review flow
Once connected, a prompt like this drives the whole workflow:
Review PR #42 on ososerp-web against our standards and post comments.
Under the hood the client will typically:
github_get_review_standards(local + repo-side)github_get_pull_request(gethead_sha)github_get_pull_request_filesorgithub_get_pull_request_diffgithub_list_review_comments(avoid duplicate feedback)github_submit_pr_reviewwith inline comments and a verdict
Managing context/token usage on large PRs
Tool results stay in context for the rest of the session, so a couple of knobs help keep big PRs from flooding it:
github_get_pull_request_filestruncates each file's patch tomax_patch_chars(default 2500) and returnspatch_truncated: truewhen it cut something off. Passinclude_patch=falsefor a filenames-only overview first, then usepaths=["src/big_file.ts"]to re-fetch just the file(s) you actually need to inspect closely (optionally with a highermax_patch_chars).github_get_pull_request_difftruncates tomax_chars(default 8000). For anything beyond a small PR, prefergithub_get_pull_request_filesinstead — it lets you review file-by-file rather than pulling the whole diff at once.- List-heavy tools return compact (non-pretty-printed) JSON to shave a bit more off every call.
The general pattern for a large PR: call github_get_pull_request_files with
include_patch=false first to see what changed, then selectively pull full
patches only for the files that look like they need real scrutiny.
6. Automate it: review every PR automatically
Rather than typing a prompt each time, you can trigger a review the moment a PR opens, using a GitHub Actions workflow that runs Claude headlessly.
Note: If your org is on a Claude Team/Enterprise plan, Anthropic also
offers a fully-managed Code Review feature (org admin enables it once,
no workflow file needed, tune it with a REVIEW.md in the repo). See
code review docs. What
follows is the self-hosted alternative that reuses this server and your
STANDARDS.md directly, works on any plan, and gives you full control over
the tools/prompt.
This repo already includes the pieces:
.github/workflows/pr-review.yml— triggers on PR opened/synchronize/reopenedmcp-config.json— tells Claude Code how to launch this server in CI
Setup:
- Copy this whole
github-pr-review-mcp/folder (including.github/workflows/pr-review.ymlandmcp-config.json) into the root of the repo you want auto-reviewed. (Or add it as a git submodule if you want it to stay in sync across repos.) - In that repo's GitHub settings → Secrets and variables → Actions, add
ANTHROPIC_API_KEY(from console.anthropic.com). - Push a test PR. Within a minute or two you should see review comments posted by the
github-actions[bot]account.
Caveats:
- The workflow uses the default
secrets.GITHUB_TOKEN, which only has write access for PRs within the same repo. PRs from forks run with a read-only token and no access to secrets by default (GitHub's security model) — reviewing external contributors' PRs automatically needs apull_request_targetworkflow instead, which is more advanced and requires care not to check out/execute untrusted code. - Each review run costs Claude API tokens (scales with PR size); consider limiting the trigger to
openedonly (dropsynchronize) if you don't need re-review on every push.
Notes on line numbers
GitHub's review-comment API expects line to be a line number that actually
appears in the diff hunk for that file (from github_get_pull_request_files'
patch field), not an arbitrary line in the full file. If a comment call
returns a 422 error, re-check the patch/hunk for that file first.
Troubleshooting
- 401 error:
GITHUB_TOKENmissing, expired, or not picked up — confirm it's set in the exact process/config running the server. - 403 error: token lacks "Pull requests" permission on that repo, or the repo is private and the token/account can't see it.
- 404 error: wrong owner/repo/PR number, or no access to a private repo.
- 422 on posting a comment: the
line/path/sidecombination doesn't correspond to a changed line in the diff.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.