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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。