# srbsa/diffgate [Health: Active]

**Category:** 💰 Finance & Fintech  
**Repository:** https://github.com/srbsa/diffgate  
**GitHub Stars:** 5  
**Views:** 2  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/srbsa-diffgate

## Description
Deterministic guardrail for AI-written diffs, runnable from inside the coding agent's own loop over MCP. Zero-LLM-token, AST-precise rules (SQLi, SSRF, XXE, permissive CORS, prototype pollution, hardcoded secrets) across 8 languages, plus structural checks for reinvented helpers and over-abstraction — findings scoped to only the changed lines, same input always gives the same output, no false-block guarantee. npm i -g diffgate-review (registers as the diffgate command; diffgate mcp starts the server)

## Tools
Capabilities this server exposes over MCP:

- **diffgate_analyze** — Analyze a file for code review findings. Only flags risk on lines changed vs the git baseline (diff-aware). Pass `content` to analyze unsaved or generated code before it is written to disk. When a code graph is available, public-surface findings carry an `impact` field (caller count, suggested reviewers, test gaps) and may be tier-adjusted — fix high-blast-radius findings before surfacing the code.
- **diffgate_check_staged** — Check all staged (or working-tree) changes in a git repo for DiffGate findings. Returns overall tier, counts, and per-file findings across the whole diff, plus a `verdict` block (the agent autonomy ladder: pass/review/blocked overall, with a rung — block/escalate/autofix/advisory — per finding) so you can decide whether to surface the diff without reimplementing the rules.
- **diffgate_deep_review** — Run an agentic deep review on a single high-impact (orange) finding. The model uses real repo tools (grep, read_file, find_references, git_blame) to investigate blast radius before rendering a verdict.
- **diffgate_explain** — Get a concise AI explanation for a DiffGate finding. Faster than diffgate_deep_review — a single LLM call with no tool loops.
- **diffgate_capabilities** — Report which DiffGate layers are active (core / code graph / LLM), which tools you can call right now without an error, and the agent autonomy budget (fix limit, escalation, trust source). Call this once up front so you know what's available instead of discovering it via thrown errors.
- **diffgate_guidelines** — Review the diff against the repo's own coding guideline files (AGENTS.md, CLAUDE.md, .cursorrules, etc.), scoped per directory (nearest file wins). IMPORTANT: if the result has mode='host', NO external model was used — this is a SELF-REVIEW, not an independent gate: YOU (the calling agent) evaluate each group's `hunks` against its `guidelines` text using your own model. Treat host-mode results as ADVISORY only — never block the change on them. If mode='model', findings were produced by the configured provider and are returned directly.
- **diffgate_feedback** — Record a reviewer's verdict on a finding so DiffGate learns. verdict 'dismiss' suppresses that same flagged code (ruleId + code) in future reviews (noise reduction); 'confirm' marks it as a real, valued catch. Stored in .diffgate/learnings.json at the repo root.

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/srbsa/diffgate), copied verbatim. Run them in order; they are not an mcpServers config.

1. Install:

```sh
npm install -g diffgate-review
```

2. Add to Claude Code:

```sh
claude mcp add diffgate -- diffgate mcp
```

3. Start the server:

```sh
diffgate mcp                   # start the MCP stdio server
```

## Documentation

## What srbsa/diffgate MCP server does

The srbsa/diffgate MCP server provides an MCP interface to DiffGate's code-review engine. It focuses on changes rather than treating every existing issue in a file as new. The engine checks changed lines for security risks such as SQL injection, SSRF, XXE, permissive CORS, prototype pollution, and hardcoded secrets. It also supports structural checks for reinvented helpers and over-abstraction across eight languages.

Results are tiered so an agent can distinguish changes that can pass, changes that need a look, and higher-impact changes that need verification. Findings can include a verdict describing whether the change should pass, be reviewed, escalated, autofixed, or remain advisory.

## How it works

Call `diffgate_analyze` for one file, including unsaved or generated content through the `content` parameter. For repository-wide review, `diffgate_check_staged` examines staged or working-tree changes and returns counts, per-file findings, an overall tier, and a verdict block.

The server compares code with the Git baseline, so unchanged lines are normally outside the review scope. When a code graph is available, public-surface findings can include caller counts, suggested reviewers, and test gaps. That information may adjust a finding's tier based on its likely blast radius.

`diffgate_deep_review` investigates one high-impact finding with repository tools such as search, file reading, reference lookup, and blame inspection. `diffgate_explain` provides a shorter explanation using one model call without a tool loop. `diffgate_guidelines` checks directory-scoped guidance files, including `AGENTS.md`, `CLAUDE.md`, and `.cursorrules`. Host-mode guideline results are advisory self-reviews rather than independent model gates.

## Setup and configuration

Install the package globally with `npm install -g diffgate-review`, then start the MCP server with `diffgate mcp`. A Claude Code registration uses `claude mcp add diffgate -- diffgate mcp`; Cursor can register the same command with `diffgate` and the `mcp` argument. Claude Desktop can use the published `diffgate.mcpb` package.

For repository setup, run `diffgate init`. It detects the language and test command and writes `.diffgate.json`. The CLI can also scan a demonstration setup with `diffgate init --demo`.

## Tools and capabilities

- `diffgate_capabilities` reports active core, code-graph, and LLM layers, available tools, and the autonomy budget.
- `diffgate_feedback` stores `confirm` or `dismiss` decisions in `.diffgate/learnings.json`; dismissals suppress matching rule-and-code findings in later reviews.
- Core checks run without LLM tokens. Model-assisted explanations, deep reviews, and configured guideline reviews use the model path described by their result mode.
- The same engine is also available through the CLI, editor extensions, pre-commit hooks, and CI, although those surfaces are outside the MCP tool interface.

## Limitations and notes

The MCP tools are most useful when a Git baseline or repository context is available. `diffgate_analyze` can inspect content that has not been written to disk, but repository-wide checks depend on the repository's staged or working-tree state. Code-graph impact fields are conditional on a graph being available.

Guideline results in host mode must not independently block a change because the calling agent performs the evaluation. Deep review is limited to a selected high-impact finding, while explanation is intentionally narrower and does not perform repository tool loops. DiffGate's published benchmark reports zero false blocks on its versioned clean-change corpus; that result is a benchmark claim, not a guarantee for every repository or codebase.

_Full upstream README: https://allmcps.com/mcp/srbsa-diffgate/readme_

