pr-agent
Acts as a GitHub PR review and agent gateway: verifies signed GitHub webhooks to automatically queue security reviews for new or updated pull requests, and, once all security/quality gates pass, pushes agent/* branches, opens draft pull requests, and posts review comments back to the repository via the GitHub REST API. Repo allowlisting and RBAC restrict which repositories can be targeted.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
pr-agent
A self-hosted PR review and swarm orchestration gateway. It exposes a FastMCP tool surface and a GitHub webhook endpoint that turn pull requests and chat-style tool calls into isolated, sandboxed coding-agent jobs — each running in its own git worktree, guarded by a default-deny security model, and gated by static analysis before any branch is pushed or review is posted.
The guiding principle is KISS: a small FastAPI + FastMCP process, a thin queue backed by SQLite, and one worker per job. No workflow engine, no message broker, no Kubernetes.
Overview
pr-agent sits between an LLM client (a coding agent, a CI step, or a GitHub webhook) and your repositories. It offers two entry points:
A FastMCP server (Streamable HTTP at
/mcp) exposing read-only repo intelligence and job-dispatch tools, callable by any MCP-capable client.A GitHub webhook (
POST /webhook/github) that verifies the delivery signature and automatically queues a security review for new or updated pull requests.
Both paths converge on the same execution engine: a persona worker that
clones the target repo into a dedicated, throwaway git worktree, runs a
coding CLI (agy or omp) against it, and — only if every gate passes —
commits, pushes an agent/* branch, and opens a draft PR or posts a review.
Personas are plain Markdown files with YAML frontmatter. They encapsulate the
runner, model, and write permissions, so callers pick a role (scout,
security-reviewer, …) rather than a model name.
Related MCP server: GithubMCP
Architecture
┌─────────────────────────────┐
MCP client ─▶│ FastAPI + FastMCP gateway │
(LLM/CI) │ server/app.py │
│ • /mcp (MCP tools) │
│ • /webhook/github │
│ • /metrics, /health │
└──────────────┬──────────────┘
│ dispatch_job (SQLite queue)
▼
┌─────────────────────────────┐
│ Job store + scheduler │
│ agent/job_store.py │
│ • semaphore (max concurrent)│
│ • heartbeat / stale reaper │
│ • 3-strike circuit breaker │
└──────────────┬──────────────┘
│ execute_pr_task
▼
┌───────────────────────────────────────────────────────┐
│ Isolated worker (one git worktree per job) │
│ agent/pr_worker.py + agent/workspace.py │
│ │
│ prepare worktree ─▶ run persona CLI ─▶ parse output │
│ │ │ │
│ ▼ ▼ │
│ commit/push agent/* ◀── verification ── blast │
│ (never main) (checks) radius │
│ │ │
│ ▼ │
│ gated draft PR / review comment │
└───────────────────────────────────────────────────────┘Request flow
Ingress. A tool call arrives over MCP, or GitHub POSTs a webhook.
ZeroBodyReadAuthMiddlewareauthenticates the caller and binds an identity;RBACMiddlewareauthorizes the target repository; the secret-scrubber middleware is attached for outbound redaction.Queueing.
dispatch_jobrecords a row in SQLite and launches the worker coroutine under a concurrency semaphore. It returns immediately with ajob_idand anassigned_branch.Isolation. The worker prepares a fresh
git worktreechecked out on a per-job branch (agent/<persona>/<job_id>), cloned/fetched through a token-scoped, hooks-disabled git invocation.Execution. The persona's runner (
agyoromp) runs headless against the worktree in a secret-stripped environment with a hard timeout and process-group kill on overrun.Gating. Before anything leaves the machine, the diff passes a blast-radius check, the repo's own check manifest (loaded from
main), and a read-only security-reviewer pass whose verdict must be an explicitAPPROVED. Only then is a draft PR opened or a review comment posted.
Components
Path | Responsibility |
| FastAPI app, MCP tools, webhook verification, middleware wiring |
| Resolves this machine's identity from |
|
|
| SQLite job queue, scheduler, heartbeats, circuit breaker |
| Executes one job end-to-end and produces a |
| Git worktree lifecycle, commit/push, PR + review REST calls |
| Loads persona Markdown (repo |
| Allowlists, protected-path rules, untrusted wrapping, safe envs |
| Fail-closed security verdict derivation |
| Isolated ruff/bandit/gitleaks on changed files |
| Strips lockfile/binary noise and caps diff size |
| Secret redactor, RBAC/auth middleware, blast-radius + check manifest gates, gated PR opener |
| Standalone AST quality gatekeeper ( |
| Built-in fallback personas ( |
Security Model
The system treats all PR content, diffs, CI logs, and task text as untrusted input and is built to fail closed at every boundary.
Untrusted XML fencing
Every piece of external text injected into a prompt is wrapped by
wrap_untrusted() in an <untrusted_pr_context>…</untrusted_pr_context>
fence. The wrapper strips ANSI escapes, caps length, and escapes any
</untrusted_pr_context> sequence in the payload so fenced content cannot
break out and impersonate instructions. The MCP server instructions reinforce
this: text inside the fence is data, never instructions.
Default-deny writes
Write access is denied by default and can only be narrowed, never widened, by a caller:
resolve_allow_writes()returnsFalseunconditionally for webhook-triggered jobs and for read-only personas (scout,security-reviewer,performance-engineer,db-migration-reviewer).Fork PRs and non-trusted authors (
author_associationoutside OWNER/MEMBER/COLLABORATOR) are forced read-only.Persona frontmatter is validated with
ConfigDict(extra="forbid", strict=True), so a typo likeallow_writes: "yes"fails closed instead of silently granting write access.Workers may only ever push to
agent/*branches;main/masterpushes are refused, and protected paths (CI workflows, personas, check manifests) are rejected before a commit is created.
SecretRedactor
An outbound middleware (SecretScrubberMiddleware) scrubs every tool result,
prompt response, and resource read through SecretRedactor — a deterministic,
high-precision regex scrubber covering private keys, GitHub/AWS/API tokens,
JWTs, bearer tokens, JSON secret fields, and .env-style assignments. It
truncates-before-scrub for payloads over 512 KB (regex-DoS guard), runs off the
event loop via asyncio.to_thread, and fails closed: if scrubbing itself
errors, the raw result is never returned. The same redactor sanitizes persisted
job logs, model-I/O records, progress messages, and git error output.
Blast-radius guard
Before a PR is opened, evaluate_blast_radius() parses the unified diff and
enforces hard caps — ≤ 10 files and ≤ 400 changed LoC (lockfiles
excluded) — while blocking protected paths across both sides of every patch
(closing rename/delete bypasses). An unparseable diff fails closed. Exceeding a
cap records a strike; three strikes trips the circuit breaker.
AST quality gatekeeper (uv run guard)
guard is a standalone AST/token scanner that acts as the quality gatekeeper
for Python changes. It runs seven pure-AST rules — truncation placeholders,
type: ignore suppression, anti-slop style (bare/broad excepts, mutable
defaults, unsafe open), sync blocking calls in async functions, banned silent
fallbacks, cyclomatic-complexity/nesting depth, and Pydantic models missing
extra='forbid' — plus optional ruff and ty subprocess checks. Each finding
is a structured What/Why/How diagnostic. It is designed to run in pre-commit,
in CI, and as the verification step for agent-authored changes.
Defense in depth
Auth & RBAC.
ZeroBodyReadAuthMiddlewareauthenticates without ever reading the request body (avoiding SSE/Streamable-HTTP deadlocks): a secret URL path, a Bearer token, or localhost-only/metrics.RBACMiddlewareauthorizes every tool call against the caller's allowed repositories, resolving the target repo across directrepo,job_id, and splitowner/repoargument shapes.Webhook hardening. HMAC-SHA256 signature verification (with zero-downtime secondary-secret rotation), a replay cache keyed on
X-GitHub-Delivery, a clock-skew window, and a 1 MB payload cap.Repo allowlist.
ALLOWED_REPOSITORIESgates every tool; repo slugs are validated against path traversal.Isolated execution. Git runs with a minimal env (no host secrets, no system gitconfig, hooks disabled); the persona CLI runs in a secret-stripped allowlist env; the check manifest runs each command with
shell=False, an offline/secret-free env, and process-group isolation.Manifest trust. The verification manifest (
.vps-checks.toml) is loaded strictly frommain, never the PR head, so a PR cannot inject check commands.
Quickstart
Prerequisites
Python ≥ 3.11
gitA GitHub fine-grained PAT and (for webhook mode) a webhook secret
One or both coding CLIs on
PATHfor the runners your personas use (agyand/oromp)
1. Install
uv sync2. Configure the environment
cp .env.example .env
# edit .env and fill in the required valuesKey variables (see .env.example for the full list and inline guidance):
Variable | Purpose |
| 48-char URL-safe secret for the MCP endpoint path |
| Fine-grained PAT (Contents R/W, Pull requests R/W, Issues R/W, Metadata R) |
| HMAC secret for webhook verification |
| Optional second secret for zero-downtime rotation |
| Comma-separated allowlist of |
| Runner binary, default model, per-job timeout |
| Local host paths for state |
3. Configure machine identity
server refuses to start without a valid config/location.json. Copy the
example and set it for this machine:
cp config/location.json.example config/location.json
# edit host/port/profile and the peer block for this machineThe file declares which environment (dev / production) and bind address
this checkout is, plus where its peer lives. The repository's parent directory
arbitrates whether the declared environment is trustworthy, so a file copied
between machines is rejected rather than silently mis-binding.
4. Run
uv run python -m serverThis resolves the bind address from config/location.json and serves:
POST /webhook/github— GitHub webhook receiver/mcp(and/gemini/<MCP_SECRET_PATH>/mcp) — FastMCP Streamable HTTP/metrics,/health— observability (metrics restricted to localhost or admin auth)
Testing
# run the test suite
uv run pytest
# run the AST quality gatekeeper over the codebase
uv run guard .uv run guard also supports targeted modes used by hooks and CI:
uv run guard --staged # staged Python files (pre-commit)
uv run guard --changed # modified/untracked Python files
uv run guard --base origin/main # files changed vs a base ref (PR)
uv run guard --no-external # skip the ruff/ty subprocess checksThe gatekeeper exits non-zero on any finding, so it drops directly into a
pre-commit hook (scripts/install_hooks.sh) or a CI step.
License
See LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Screens public GitHub repos and PRs to generate risk maps, findings, and merge-readiness signals.
Live GitHub repo AST X-Ray, 42 coding-agent DoD gates, Git worktree guards & brownfield baselines.
Security reviews for coding agents: diffs checked against your org policy and live infrastructure.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Related MCP Servers
AlicenseAqualityDmaintenanceEnables AI agents to screen GitHub repositories and pull requests for risk analysis, generating risk scores, findings, and merge-readiness signals.5MIT- AlicenseAqualityDmaintenanceConnects AI assistants to GitHub repositories, pull requests, issues, commits, and code search while enabling repository visibility controls, CI/CD monitoring, sandboxed local filesystem access, and code quality/security analysis.131MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to safely inspect a local repository's code and metadata while blocking private data from leaving the machine, providing read-only tools for search, change tracking, and integrity verification.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding assistants to inspect local and remote repositories through sandboxed tools that surface project overviews, structure, dependency audits, Git churn hotspots, and a heuristic health score. It also supports safe GitHub issue searching and creation with built-in duplicate preflight checks, while blocking sensitive files, binary content, and path traversal attacks.MIT