Skip to main content
Glama

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 semgrep or brew install semgrep)

    • Playwright (npm i -D @playwright/test and npx playwright install)

Related MCP server: CodeChecker MCP

Installation

  • Clone this repo (or copy tools/mcp-code-review.mjs and .mcp/code-review/ into your project repo)

  • Install Node deps in the repo: npm ci (or npm i)

  • Ensure .cursor/mcp.json points to the absolute path of tools/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_KEY

    • FIGMA_TOKEN

    • SEMGREP_RULES_DIR=.mcp/code-review/semgrep-rules

Project files the MCP auto-detects

  • Repo docs (AI context):

    • codebase_structure.md and watchouts.md at repo root

    • All .md under .mcp/code-review/ (e.g., your-rules.md)

  • Lint/format/types:

    • ESLint/Prettier run from local node_modules/.bin using your project configs

    • TypeScript runs if tsconfig.json exists

  • Security:

    • Semgrep rules from .mcp/code-review/semgrep-rules/ if present, otherwise p/ci

  • Tests:

    • Playwright runs if playwright.config.ts/js exists at repo root

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-fix or --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.mcp is present and logs show Auth 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.

Available Tools

9 tools
analysis.run_staticRun StaticC

Run ESLint/tsc/Prettier on files

Inputs: files (required), runPrettier, runTsc.

cleanup.prunePrune ArtifactsC

Prune old logs and reports

Inputs: owner (required), pull_number (required), repo (required).

code-reviewAI Code ReviewC

Run an AI-powered code review for a GitHub PR. Usage: @code-review [prId] [--flags]

Inputs: aiOutput, options, prId.

github.fetch_filesFetch PR FilesC

Fetch files/diff for a PR

Inputs: owner (required), pull_number (required), repo (required).

github.resolve_prResolve PRD

Resolve owner/repo and PR number from an input

Inputs: prId (required), options.

jira.fetchFetch JiraC

Fetch Jira tickets by keys or from prMeta

Inputs: keys, options, prMeta.

report.generateGenerate ReportC

Generate a code review report markdown

Inputs: owner (required), prUrl (required), pull_number (required), repo (required), +6 more.

security.run_semgrepRun SemgrepD

Run Semgrep scan

Inputs: files, rulesDir.

tests.run_playwrightRun PlaywrightD

Run Playwright tests

Inputs: full, grep.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.5/5.0

    Scored across 9 tools

    Disambiguation4/5

    Most tools have distinct purposes, such as static analysis, security scanning, and test running, but there is some potential overlap between 'analysis.run_static' and 'security.run_semgrep' as both involve code analysis, which could cause confusion. The descriptions help clarify their focuses, but the boundaries are not perfectly clear.

    Naming Consistency2/5

    The naming conventions are inconsistent, mixing dot notation (e.g., 'analysis.run_static'), hyphenated names (e.g., 'code-review'), and snake_case (e.g., 'github.fetch_files'). There is no uniform pattern, making the set less predictable and harder for agents to parse reliably.

    Tool Count5/5

    With 9 tools, the count is well-scoped for a code review server, covering key areas like analysis, security, testing, reporting, and integration with GitHub and Jira. Each tool appears to serve a specific function without redundancy, fitting the domain appropriately.

    Completeness4/5

    The toolset covers core code review workflows, including fetching PR data, running analyses, generating reports, and integrating with external systems. A minor gap is the lack of tools for managing or updating review comments or statuses, but agents can work around this with the existing tools.

    Related MCP Connectors

    Related MCP Servers