Code Review MCP
Enables comprehensive GitHub PR reviews through Cursor's AI by fetching PR diffs, running static analysis tools (ESLint, Prettier, TypeScript, Semgrep), executing tests, and generating detailed code review reports with inline comments.
README
Code Review MCP — Cursor-first PR reviewer
End-to-end MCP that reviews GitHub PRs using your local toolchain and Cursor’s AI. It fetches PR diffs, loads project docs, runs static/security/tests, posts inline comments (when allowed), and generates a Markdown report.
Requirements
- Node.js 18+
- Cursor
- GitHub Personal Access Token (repo permissions) — loaded via
.env.mcp - Optional tools (auto-detected; skipped if missing):
- ESLint, Prettier, TypeScript (
tsc) from project devDependencies - Semgrep CLI (
pipx install semgreporbrew install semgrep) - Playwright (
npm i -D @playwright/testandnpx playwright install)
- ESLint, Prettier, TypeScript (
Installation
- Clone this repo (or copy
tools/mcp-code-review.mjsand.mcp/code-review/into your project repo) - Install Node deps in the repo:
npm ci(ornpm i) - Ensure
.cursor/mcp.jsonpoints to the absolute path oftools/mcp-code-review.mjs
Example .cursor/mcp.json:
{
"mcpServers": {
"code-review": {
"command": "node",
"args": ["/absolute/path/to/tools/mcp-code-review.mjs"]
}
}
}
Environment (auth)
- The MCP loads only
.env.mcp(repo root) by default, or--env-file=/path/to/env - Required:
GITHUB_TOKEN=...(must have access to the target repo; SSO-authorized if org enforces it)
- Optional:
JIRA_BASE_URL,JIRA_EMAIL,JIRA_API_KEYFIGMA_TOKENSEMGREP_RULES_DIR=.mcp/code-review/semgrep-rules
Project files the MCP auto-detects
- Repo docs (AI context):
codebase_structure.mdandwatchouts.mdat repo root- All
.mdunder.mcp/code-review/(e.g.,your-rules.md)
- Lint/format/types:
- ESLint/Prettier run from local
node_modules/.binusing your project configs - TypeScript runs if
tsconfig.jsonexists
- ESLint/Prettier run from local
- Security:
- Semgrep rules from
.mcp/code-review/semgrep-rules/if present, otherwisep/ci
- Semgrep rules from
- Tests:
- Playwright runs if
playwright.config.ts/jsexists at repo root
- Playwright runs if
Usage
In Cursor chat inside the target repo:
@code-review 123(auto-detect repo from git origin)@code-review owner/repo#123@code-review https://github.com/owner/repo/pull/123@code-review latest
Flags:
--env-file=/abs/path/to/.env.mcp(override default)--dry-run(skip posting/comments, still generate report)--commit-report(commit report to PR branch when permitted)--auto-fixor--auto-fix=force(apply ESLint/Prettier fixes, commit & push)--skip-static--skip-security--skip-tests--skip-figma--semgrep-rules-dir=/path/to/rules(override rules)--max-diff-chars=20000--max-file-hunks=10--verbose
Outputs:
- Logs:
mcp-logs/(per-run files) - Artifacts:
mcp-artifacts/<owner>-<repo>-PR<#>-<ts>/ - Report:
mcp-reports/code-review-<owner>-<repo>-PR<#>-<ts>.md
Notes:
- If the authenticated user is the PR author, GitHub may reject review posting; the MCP will skip comments but still write the report (see Pipeline Status in the report).
- Older logs/reports (>1 day) are pruned, and only the latest report for a PR is kept.
Sub-tools (advanced)
You can call focused tools directly:
@github.resolve_pr { prId: "owner/repo#123" }@github.fetch_files { owner: "owner", repo: "repo", pull_number: 123 }@jira.fetch { prMeta: { title: "...", body: "...", branch: "..." } }@analysis.run_static { files: ["src/..."], runTsc: true }@security.run_semgrep {}@tests.run_playwright {}@report.generate {...}@cleanup.prune { owner:"owner", repo:"repo", pull_number:123 }
CI recommendations
Run the same tools in CI for consistent enforcement:
- ESLint:
npx eslint . --max-warnings=0 - Prettier:
npx prettier --check . - Semgrep:
pipx install semgrep && semgrep --config .mcp/code-review/semgrep-rules --error -- . - Playwright:
npx playwright install --with-deps && npx playwright test --reporter=line
Troubleshooting
- Bad credentials: ensure
.env.mcpis present and logs showAuth loaded from .env.mcp:.... Verify PAT:curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/user→ must be 200. - Jira skipped: ensure Jira key in PR branch/title/body, and
JIRA_*are set. - Semgrep skipped: install CLI or set rules dir.
- Playwright skipped: add
playwright.config.*and install browsers.
For platform-specific setup (macOS/Windows), see docs/Platform-Setup.md.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。