ai-review
Provides tools for fetching pull requests, files, repository structure, and posting review comments on GitHub, enabling automated code review of pull requests.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ai-reviewReview PR #123 and suggest improvements"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
AI Code Review Agent
An autonomous GitHub pull-request review agent built on Claude + MCP + RAG.
When a PR is opened or updated, a webhook enqueues a background job. A worker loads the repo's config, pulls the diff, retrieves relevant context from a RAG index of the codebase, and runs a Claude tool-use loop that inspects files and submits a structured review. Comments are filtered (severity threshold, ignored paths, previously-dismissed suggestions) and posted back to the PR as a single batched GitHub review. The same five review tools are also exposed over a Model Context Protocol (MCP) stdio server so you can drive them from Claude Code interactively.
The whole system runs and tests green with zero external API keys — Claude, OpenAI embeddings, ChromaDB, Redis, and Postgres are all optional. When a dependency is absent the code degrades gracefully (local embedder, in-memory vector store, in-memory idempotency, and a static regex-based fallback review).
Architecture
GitHub PR event
│ (HMAC-signed webhook)
▼
┌───────────────────────────────┐
│ Webhook (FastAPI) │ src/ai_review/webhook/
│ • verify signature │
│ • idempotency (delivery_id) │
│ • enqueue Celery task │
└───────────────┬───────────────┘
│ Redis queue "reviews"
▼
┌───────────────────────────────┐
│ Worker (Celery) │ src/ai_review/worker/
│ 1. load .github/ai-review.yml│
│ 2. fetch PR + diff (GitHub) │
│ 3. RAG context prefetch │──► RAG service (src/ai_review/rag/)
│ 4. Claude agent loop ────────┼──► tools.py (5 shared tools)
│ ↳ fallback: static rules│ ▲
│ 5. filter (threshold / │ │ same tools
│ ignore / learning) │ │
│ 6. post batched review │ ┌─────┴─────────────────┐
└───────────────────────────────┘ │ MCP stdio server │
│ (Claude Code) │
└───────────────────────┘
Cross-cutting: settings, models, github_client, learning store,
Prometheus metrics, structlog JSON logging.Key idea: the five review tools (github_get_pr, github_get_file,
github_get_repo_structure, github_post_review_comment, rag_query_repo)
live in one shared module, src/ai_review/tools.py.
Both the MCP server and the worker's agent loop call the same functions, so
behaviour is identical whether Claude drives them interactively over MCP or the
worker drives them autonomously.
Related MCP server: PR Reviewer MCP Server
Requirements
Python 3.11+
Optional for full deployment: Redis, Postgres, ChromaDB, Docker
Optional API keys:
ANTHROPIC_API_KEY(real reviews),OPENAI_API_KEY(OpenAI embeddings). Without them the system uses offline fallbacks.
Setup
python -m venv .venv
source .venv/Scripts/activate # Windows (Git Bash); use .venv/bin/activate on macOS/Linux
# Install the extras you need. For everything + dev tooling:
pip install -e ".[webhook,worker,mcp,rag,dev]"Optional extras, if you only want part of the system:
Extra | Pulls in | For |
| fastapi, uvicorn, redis, celery | the HTTP webhook service |
| celery, redis, anthropic, httpx, crypto | the review worker |
| mcp, httpx | the MCP stdio server |
| chromadb, openai | persistent RAG / OpenAI emb. |
| pytest, ruff, mypy | tests + linting |
Copy the environment template and edit as needed:
cp .env.example .envEverything in .env is optional for a local run — the defaults use SQLite, a
local embedder, and in-memory fallbacks.
Running the tests
pytest -q50 tests, all hermetic (no network, no API keys). Lint with:
ruff check .Running the services locally
Webhook (FastAPI)
uvicorn ai_review.webhook.app:app --reload --port 8000Endpoints:
Path | Purpose |
| GitHub webhook receiver (HMAC-verified) |
| liveness |
| readiness |
| Prometheus metrics |
Set GITHUB_WEBHOOK_SECRET to the same value configured on the GitHub App/repo
webhook. Requests with a missing or bad X-Hub-Signature-256 get 401.
Worker (Celery)
celery -A ai_review.worker.tasks worker -Q reviews --loglevel=info --concurrency=4Needs Redis (REDIS_URL). Without ANTHROPIC_API_KEY the worker still runs and
posts a static fallback review (regex rules for leaked secrets, verify=False,
eval(...), SQL string concatenation, etc.), so the pipeline is testable
end-to-end offline.
MCP server (Claude Code)
python -m ai_review.mcp_serverThis speaks MCP over stdio. To wire it into Claude Code, point your MCP config at
it — see examples/claude_mcp_config.json:
{
"mcpServers": {
"ai-review": {
"command": "python",
"args": ["-m", "ai_review.mcp_server"],
"env": {
"GITHUB_APP_ID": "123456",
"GITHUB_PRIVATE_KEY_PATH": "/absolute/path/to/app-private-key.pem",
"GITHUB_TOKEN": "",
"EMBEDDING_PROVIDER": "local"
}
}
}
}For quick local experiments you can set GITHUB_TOKEN to a personal access
token instead of configuring a full GitHub App.
Choosing an LLM provider
The review agent defaults to Anthropic, but the same agent loop runs against any OpenAI-compatible endpoint through a built-in adapter — so you can use free providers like NVIDIA NIM, Groq, OpenRouter, or a fully local Ollama. Only env vars change; no code changes.
NVIDIA NIM (free credits at build.nvidia.com):
LLM_PROVIDER=nvidia
NVIDIA_API_KEY=nvapi-...
# Defaults (override if you like):
# LLM_BASE_URL=https://integrate.api.nvidia.com/v1
# LLM_MODEL=meta/llama-3.3-70b-instructAny other OpenAI-compatible provider:
LLM_PROVIDER=openai_compat
LLM_API_KEY=...
LLM_BASE_URL=https://api.groq.com/openai/v1 # or openrouter / ollama / …
LLM_MODEL=llama-3.3-70b-versatileProvider |
| Example model |
NVIDIA NIM |
|
|
Groq |
|
|
OpenRouter |
|
|
Ollama (local) |
|
|
Tool-calling matters. The agent works by having the model call a
submit_reviewtool. Large models (Llama 3.3 70B and up) do this reliably; very small local models may not, in which case the pipeline falls back to the static review. NVIDIA's 70B-class models are a safe default.
The Anthropic path is unchanged — leave LLM_PROVIDER=anthropic (the default)
and set ANTHROPIC_API_KEY to use Claude. With no provider key set at all, the
worker still posts the static fallback review.
Docker deployment
cp .env.example .env # fill in real values first
docker compose up --buildCompose brings up: redis, postgres, chromadb, the webhook service
(port 8000), 3 worker replicas, prometheus (9090), and grafana (3000).
The webhook and worker images install only the extras each service needs
(see docker/webhook.Dockerfile and
docker/worker.Dockerfile).
Expose the webhook publicly (reverse proxy / tunnel) and register that URL as
the GitHub App's webhook, using the same GITHUB_WEBHOOK_SECRET.
Per-repository configuration
Repos control the agent via .github/ai-review.yml (see the sample
.github/ai-review.yml in this repo):
review:
enabled: true
severity_threshold: warning # info | warning | error
categories: # per-category on/off
security: true
correctness: true
performance: true
architecture: true
testing: true
style: false
ignore_paths: ["*.lock", "vendor/**", "**/*.generated.*", "**/migrations/**"]
max_comments_per_pr: 50
require_approval_for: [] # e.g. ["security:error"]
custom_rules: | # extra natural-language rules for the agent
- "All API endpoints must have rate limiting"
learning:
enabled: true
dismissed_suggestion_ttl_days: 30Config is fetched from the target repo, validated with pydantic, and cached with a TTL. Missing/invalid config falls back to sane defaults.
Environment variables
Variable | Default | Notes |
| – | GitHub App ID (production auth) |
| – | App PEM (inline or file) |
| – | HMAC secret; required for the webhook |
| – | PAT fallback for local dev (not for prod) |
| – | Enables real Claude reviews; empty → static fallback |
|
| Review model (Anthropic provider) |
|
|
|
| – | NVIDIA NIM key (when |
| provider default | Overrides the model; NVIDIA default |
| provider default | OpenAI-compatible endpoint; NVIDIA default |
|
|
|
| – | Required only when provider is |
|
| Celery broker / idempotency |
|
| Learning store |
|
| Empty host → embedded persistent client |
|
| Local Chroma path when no host |
|
| Hard cap on posted comments |
|
| Per-review budget |
|
| structlog config |
See .env.example for the full list.
How a review is decided
Categories & priority (highest → lowest): security → correctness → performance → architecture → testing → style.
Severity threshold: comments below the repo's threshold are dropped.
Line targeting: inline comments only attach to lines actually added in the diff.
Learning suppression: suggestions a maintainer previously dismissed are fingerprinted and suppressed for
dismissed_suggestion_ttl_days.Quality score:
100 − Σ(category_weight × severity_weight), clamped to[0, 100], plus the top concerns, are included in the summary comment.
Every posted review carries an AI-generated disclaimer.
Runbook
A PR opened but no review appeared.
Check the webhook received it: webhook logs +
GET /metrics(webhook_events_total). A401means the signature/secret is wrong.Check the worker consumed it: worker logs for the
reviewsqueue, and that Redis is reachable (REDIS_URL).If Claude is unreachable/no key, a static fallback review should still post — its absence points at GitHub auth (App token or
GITHUB_TOKEN) or the target-repo permissions.
Duplicate reviews.
Idempotency is keyed on the GitHub
X-GitHub-Deliveryid via RedisSET NX. If Redis is down, the in-memory fallback only dedupes within a single process, so duplicates are possible across replicas — restore Redis.
Reviews are too noisy / too quiet.
Tune
review.severity_thresholdandreview.categoriesin the repo's.github/ai-review.yml. Lower the threshold toinfofor more comments, raise toerrorfor only the most serious.
A recurring false positive keeps coming back.
Dismiss the comment on GitHub; the deletion webhook records it in the learning store and it's suppressed for
dismissed_suggestion_ttl_days. Confirmlearning.enabledis true.
Metrics / dashboards.
Prometheus scrapes the webhook
/metrics; Grafana is preconfigured indocker-compose.yml(admin password viaGRAFANA_PASS). Key series:webhook_events_total,reviews_total,mcp_calls_total,review_duration_seconds.
Project layout
src/ai_review/
settings.py # env config (pydantic-settings)
models.py # ReviewComment, ReviewResult, PRRef, weights
diff_utils.py # unified-diff parsing → changed/added lines
github_client.py # httpx GitHub client (PRs, files, tree, post review)
github_auth.py # GitHub App installation tokens (PyJWT) + PAT fallback
tools.py # the 5 shared review tools
config_repo.py # .github/ai-review.yml loader + validation
learning.py # dismissed/accepted suggestion store (SQLAlchemy)
metrics.py # Prometheus metrics
logging_config.py # structlog JSON logging
webhook/ # FastAPI app, signature verify, idempotency
worker/ # Celery task, Claude agent loop, fallback, pipeline,
# scoring, filtering, prompts, rendering
rag/ # chunking, embeddings, ingest, service (Chroma/in-mem)
mcp_server/ # MCP stdio server exposing tools.py
tests/ # 50 hermetic tests
docker/ # webhook + worker Dockerfiles
docker-compose.yml # full local stack
examples/ # Claude Code MCP configDesign notes
Offline-first. Every external dependency has a fallback so the system is runnable and testable without accounts or keys. Swap in real Claude / OpenAI / Chroma / Redis / Postgres by setting env vars — no code changes.
One tool implementation. MCP and the autonomous worker share
tools.py, eliminating drift between interactive and automated review.Graceful degradation over failure. If Claude is unavailable the worker posts a static rule-based review rather than nothing (PRD NFR 4.2).
License
MIT.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceConnects Claude to GitHub Pull Requests to fetch and filter code diffs for AI-assisted reviews. It enables listing open PRs and analyzing changes while automatically excluding binary and asset files to focus on relevant code.21MIT
- FlicenseAqualityBmaintenanceConnects Claude to GitHub, enabling listing repositories, browsing open pull requests, and inspecting PR diffs for code review.4
- FlicenseAqualityDmaintenanceEnables Claude to access and manage GitHub repositories dynamically at runtime, including private repos, with tools for browsing files, searching code, and viewing commits, pull requests, and issues.111
- Alicense-qualityCmaintenanceEnables pull-request review workflows on Bitbucket Cloud via Claude Code, offering tools to view PR metadata, comments, diffs, and to post comments or approve.4,438MIT
Related MCP Connectors
AI code review for GitHub PRs with an MCP autofix loop for Claude Code and Cursor
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Repo intel for AI coding agents: overview, PRs, contributors, hot files, CI, deps. Remote MCP.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mdanouf44-cyber/Code-review-agent-with-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server