Skip to main content
Glama

PatchPilot MCP

PatchPilot — review the change, not the entire project

A focused review loop, not a fresh repository scan.

Version Local tests GitHub Actions GitHub stars

Python Protocol CLI License

PatchPilot helps coding agents and developers inspect explicitly supplied changes after an edit. It extracts changed line locations, highlights ordinary Python correctness and maintainability issues, strict JSON syntax and duplicate object keys, tracks a change budget and guides targeted testing. A caller-retained manifest allows repeated reviews to skip unchanged, previously reviewed source. It does not execute project code, edit files, inspect the workspace, perform security analysis or contact external services.

Review contract: your agent supplies the diff and the affected source, PatchPilot returns observations and next actions. The agent decides what to fix and runs the relevant project tests.

Review a change in four steps

  1. Capture. Supply a unified diff of only the current edit.

  2. Locate. Read the reported added-line locations and budget. Include removed behavior in your review.

  3. Inspect. Supply affected Python modules or complete syntactic snippets for correctness/maintainability checks; set the starting source line so findings map to the original file.

  4. Close the loop. Address findings in context, rerun the focused review after each edit, and run relevant project tests.

Use the same module or changed scope, not a new full-repository read, when the next patch is small. PatchPilot cannot observe your editor automatically and does not know what was changed unless the caller provides it.

Quick start: MCP

Requires Python 3.10+ and the official MCP Python SDK.

git clone https://github.com/ahmedsaeed1-eng/patchpilot-mcp.git
cd patchpilot-mcp
python -m pip install .

Register the installed entry point with Codex:

codex mcp add patchpilot -- patchpilot-mcp
codex mcp list

If the entry point is not available on your PATH, configure the absolute path to the Python executable in your environment and use the module invocation.

Codex MCP configuration:

[mcp_servers.patchpilot]
command = "/absolute/path/to/python"
args = ["-m", "patchpilot.server"]

Claude Desktop MCP configuration (use the same installed Python environment):

{
  "mcpServers": {
    "patchpilot": {
      "command": "/absolute/path/to/python",
      "args": ["-m", "patchpilot.server"]
    }
  }
}

Restart or reconnect the host if required. All four tools use stdio and expose structured JSON results.

Quick start: explicit CLI

From the checkout, the CLI needs only the Python standard library. The caller supplies text via stdin.

python -m patchpilot diff < examples/inventory.diff
python -m patchpilot python --path inventory.py --complete-module < inventory.py
python -m patchpilot json < examples/settings.json
python -m patchpilot snapshot < examples/snapshot.json

Replace the illustrative filename with an actual affected source file. The tool itself never opens a path; redirection is performed by the calling shell. You can also install the project and call patchpilot instead of python -m patchpilot.

For a caller-controlled Git workflow, supply the particular staged diff:

git diff --cached --no-color | python -m patchpilot diff

The tool never invokes Git; that command is a separate explicit action by the caller. CLI output is JSON on stdout. Exit code 0 means there is no detected error-level finding (warnings may still exist), 1 means a Python or JSON syntax/context error was found, and 2 means malformed or rejected input.

Related MCP server: change-impact-assistant

What the review reports

Finding

Severity

Evidence

PYTHON_SYNTAX

error

fact about supplied text in isolation

JSON_SYNTAX

error

grammar error in supplied JSON text

JSON_DUPLICATE_KEY

warning

repeated decoded key in one JSON object

DUPLICATE_LITERAL_KEY

warning

fact: repeated constant dict key

CHANGE_BUDGET

warning

fact: changed lines or files exceed selected budget

TRAILING_WHITESPACE

info

fact about the added line; removal may be inappropriate

UNREACHABLE_STATEMENT

warning

heuristic: direct statement after unconditional terminator

DUPLICATE_DEFINITION

warning

heuristic: repeated sibling definition

BRANCH_COMPLEXITY

warning

heuristic: branch score meets or exceeds threshold

POSSIBLY_UNUSED_IMPORT

info

heuristic: no explicit read in complete supplied module

NO_TEST_PATH

info

heuristic: common test-path naming conventions

Each MCP/CLI finding contains id, code, severity, evidence, path, line, message and recommendation. JSON findings and repeated Python literal keys also include a one-based Unicode-character column. IDs deduplicate equal observations and are stable only when label, code, position and message remain equal. They are not guaranteed across line moves. A null line means the observation applies to the diff as a whole. Python checks never execute the submitted source: AST parsing and syntax compilation are used only to validate the supplied text; compiled objects are discarded.

The example diff reports two changed files, four additions, one deletion and churn of five. Its test plan points to new lines in inventory.py and tests/test_inventory.py.

Tools

review_diff

Argument

Meaning

Default / range

diff

Unified diff text (required)

text

change_budget

Combined additions and removals

300 / 1–10000

file_budget

Number of file sections

10 / 1–100

Returns counts, per-file added and removed line coordinates, common test paths, focused review suggestions, and budget status. The review effort label describes change size only, not security or a correctness pass.

review_python

Argument

Meaning

Default / range

source

Python text (required)

text

path

Display label, not a file path to open

snippet.py

start_line

First original source line represented in snippet

1 / 1–100000000

complexity_threshold

Warning threshold of simple branch score

10 / 2–50

complete_module

Allow best-effort unused import hints

false

The AST branch score starts at one, then counts selected control-flow branches, boolean transitions, match cases and comprehensions; nested callable bodies are scored independently.

review_json

Supply source (strict JSON text), optional path and start_line (defaults document.json, 1). Grammar checks include arrays, objects, literals, strings and numbers, including valid large-exponent numbers. Repeated keys are identified per object using their decoded names and exact one-based line/column coordinates. The tool does not validate schemas; duplicate object keys are a warning because different readers may retain different values.

review_snapshot — incremental review

A manifest is a small source-identity record, not a storage layer or attestation. Pass a batch of explicit source entries, then retain the returned metadata-only manifest for the next invocation.

{
  "entries": [
    {"path":"inventory.py","source":"def count(): return 3"},
    {"path":"settings.json","source":"{\"quantity\":3}"}
  ],
  "complete_snapshot": true
}

Next, supply entries from the current edit and the previous response's manifest as previous_manifest. You may omit unchanged paths in a partial batch, or supply a previously computed SHA-256 digest instead of source. The tool never generates digests by opening files.

Entry field

Meaning

path

Logical display label, unique per batch

source

Explicit UTF-8 file content or fragment

digest

Optional lowercase SHA-256 of exact UTF-8 text; required without source

language

Optional python, json, javascript, typescript, unknown; inferred from extension otherwise

complete

True for full files (default); false for fragments

start_line

Original line represented by first line; default 1, must equal 1 for complete files

A supplied source and digest must match. Same-digest entries additionally need matching language, completeness, offset and review profile to skip an already reviewed file. Missing review stamp triggers analysis when source is supplied. Use recheck_unchanged: true to request another pass, and complexity_threshold to change the Python heuristic (2–50, default 10).

Status / coverage

Meaning

added, changed

Identity metadata differs from previous manifest

unchanged

Identity metadata matches; may be checked if previously unchecked

removed

Not included in an explicitly complete inventory

omitted_unknown

Missing from a partial batch; prior metadata retained, current identity unknown

checked_complete / checked_fragment

Source was analyzed in this call; fragment results only cover text supplied

not_rechecked

Previously supplied review stamp and matching profile/digest; no analysis this call

unknown_digest_only / unknown_unsupported_language / unknown_input_limit

No syntax result available

Outputs include per-file coverage, syntax status or null, finding counts, targeted test suggestions, deduplicated findings sorted by severity, and an updated metadata-only manifest. No earlier findings are returned for skipped entries; retain and reconcile those separately if your workflow needs an open-findings list. A stamp saying reviewed: true means reviewed, not clean; stamps from callers are not independently verified. A null syntax result never means a pass.

Use complete_snapshot: true only when the supplied list represents the full inventory; otherwise omission never means deletion. Snapshot requests cap each manifest at 100 entries, each source at 256 KiB/6,000 LF-delimited lines, and combined raw source at 1 MiB. JSON nesting is capped at 100. Up to 100 distinct findings are returned per review; snapshot reports aggregate omitted findings from available per-source results. Run a focused direct review if a source's own cap is reached.

Example stdin request: examples/snapshot.json. The host can retain the returned manifest between calls; PatchPilot does not persist it.

Instruction template for coding agents

Add the following to your project-specific Codex/Claude instructions if you want a review after every edit:

After each edit (including new code):
1. Supply only the current unified diff to PatchPilot review_diff.
2. For changed Python snippets, supply complete affected definitions or the
   affected module to review_python, with path label and correct line offset.
   Mark complete_module only if the entire module was supplied.
3. Review changed JSON with review_json. For repeated batches, carry the
   review_snapshot manifest forward and inspect previously unknown coverage.
4. Report error-level findings first; validate warnings and heuristics
   against the surrounding behavior before changing anything.
5. Fix verified problems, preserving existing behavior and scope.
   Re-run both reviews on the revised change. Run the smallest relevant
   project test set using the project's normal test tooling.
6. Finish with a summary of findings addressed, remaining limitations,
   and actual test results. Never claim tests passed unless they ran.

This is a caller-side convention, not an automatic watcher or enforcement hook. Python and JSON have language-specific checks. JavaScript/TypeScript and other languages have diff tracking and test planning only; language coverage is explicitly unknown, not syntax-passed.

Boundaries

  • Each input is capped at 256 KiB and 6,000 lines. Diff sections: 100. Python AST: 20,000 nodes. Findings: 100. Test-plan line targets: first 30 added and first 30 removed lines per file, separately.

  • Standard text unified diffs with file headers and hunks are supported. Binary, copy, quoted-path, rename-only, mode-only and combined diffs are unsupported. File labels are never opened; timestamps are supported only when tab-separated.

  • Syntactically valid code can still be wrong. Code fragments depending on omitted context may report syntax errors in isolation. Import hints are conservative, cannot resolve dynamic references or side effects, and must not be interpreted as proof of dead code.

  • No type checking, dependency analysis, whole-project context, runtime behavior validation, security checks, test execution, automatic editing or formatting. Trailing whitespace is reported, not automatically deleted.

  • Do not supply secrets or personal data. PatchPilot works with input text only, but the caller controls how text reaches its MCP host.

Development

python -m unittest discover -s tests -v

Tests cover diff parsing, exact line mapping, malformed and bounded inputs, Python syntax/context, branch score, dictionary keys, definition and import hints, JSON grammar and duplicate coordinates, changed-only snapshot behavior, profile changes, digest-only coverage, findings caps and stable IDs, CLI output and the official MCP client over a real stdio session. The GitHub Actions workflow is configured for Python 3.10 and 3.12 on Linux, Windows and macOS; consult actual workflow results.

MIT licensed. See LICENSE and THIRD_PARTY.md.

Available Tools

4 tools
review_diffB
Read-onlyIdempotent

Count changed lines, report budget, and plan focused tests from supplied unified diff. No tests run.

Inputs: diff (required), file_budget, change_budget. Returns: object

review_jsonB
Read-onlyIdempotent

Inspect strict JSON syntax and repeated object keys, with exact source coordinates.

Inputs: source (required), path, start_line. Returns: object

review_pythonB
Read-onlyIdempotent

Analyze supplied Python text for syntax and maintainability. Set complete_module only for a full module. Path is a label only.

Inputs: source (required), path, start_line, complete_module, +1 more. Returns: object

review_snapshotA
Read-onlyIdempotent

Review added, changed and previously unchecked supplied source; return a metadata-only manifest for next time. Paths are labels. Missing paths are unknown unless complete_snapshot is true.

Inputs: entries (required), complete_snapshot, previous_manifest, recheck_unchanged, +1 more. Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 4 tools

    Disambiguation4/5

    Each tool targets a distinct input type: diffs, Python source, JSON text, and snapshot state. There is some potential overlap between review_snapshot and the language-specific reviewers, but the descriptions make their boundaries reasonably clear.

    Naming Consistency5/5

    All four tools follow a consistent review_noun pattern (review_diff, review_python, review_json, review_snapshot). The convention is uniform and predictable.

    Tool Count5/5

    Four tools is a well-scoped set for a focused code-review assistant. Each tool covers a distinct review target without redundant operations.

    Completeness4/5

    The surface covers diff, Python, JSON, and snapshot review, which is solid for the apparent domain. Minor gaps exist, such as no generic non-Python/non-JSON file review and no explicit test execution, though the latter is clearly out of scope.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers