# AdversaryGate [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/Sanflow10/adversary-gate  
**GitHub Stars:** 3  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/adversarygate

## Description
Fail-closed merge gate an agent calls before saying done: MERGE, BLOCK or INCONCLUSIVE.

## Tools
Capabilities this server exposes over MCP:

- **verify_repo** — Judge the working tree of a git repository against a baseline, by running its tests.

    When to call: after changing code in ``repo`` and before reporting the task
    as done. Call ``gate_policy`` first if you need to know the floors or
    whether the baseline is pinned. Python/pytest only; changes in other
    languages come back inconclusive.

    What it does: writes the baseline commit's tree (every file as committed),
    diffs it against the working tree (uncommitted and untracked files
    included), runs the suite under coverage.py, then runs the gate: the
    claims on the baseline and on the patch, the baseline's copy of any test
    the patch rewrote, and mutation testing on the changed lines. Nothing is
    committed or reverted.

    Side effects: the repository's tests execute -- its code runs, so they may
    do whatever they do when you run pytest yourself. The coverage run uses the
    repository as working directory; the gate's own files go to a temporary
    directory that is removed afterwards. It can take minutes. A run longer
    than ``timeout_seconds`` (default 3600: the gate's own full-suite run may
    take 900 alone) returns inconclusive, never a pass, and its
    ``next_steps`` names ``timeout_seconds`` as the limit to raise.

    Arguments: ``repo`` is a path inside the git repository. ``claims`` are
    pytest node ids (``path::test``) to verify; empty -> discovered from the
    tests that executed a changed line. ``pytest_args`` are test paths or node
    ids the coverage run collects (default: the whole suite); options such as
    ``-k`` are refused. ``base_ref`` is used only when the operator did not pin
    ADVERSARY_GATE_BASE_REF.

    Returns ``decision`` (merge / block / inconclusive), ``mergeable``,
    ``fix_proven``, ``reason``, per-claim results with the oracle used,
    ``diff_coverage``, ``suite_strength``, ``next_steps`` and the full
    artefact. merge permits a human review, not a release; block means fix the
    code, not the tests; inconclusive means something was not measured -- say
    what. ``next_steps`` lists what would earn a MERGE (cover these lines, kill
    this surviving mutant, add a new test, fix the code); do them and call
    again. It never asks you to edit an existing test, a harness file or a
    floor, and doing so does not help: the baseline's tests are the oracle.
    
- **gate_policy** — Show the verification policy this server enforces: floors, baseline, interpreter, and what the caller may set.

    When to call: before ``verify_repo``, to learn whether the baseline is
    pinned by the operator or chosen by you, which interpreter runs the tests,
    and which floors a merge has to clear -- or after an inconclusive or block
    answer, to explain it.

    Read-only and fast: it runs no tests and changes nothing. The policy comes
    from the server's environment (ADVERSARY_GATE_POLICY, _BASE_REF, _PYTHON),
    set by whoever configured the server; no tool can change it.

    Returns ``version``, ``operator_flags``, ``defaults``, ``baseline``,
    ``python`` and ``agent_controls`` (the arguments of ``verify_repo`` you
    decide). An invalid operator policy returns ``error`` instead.
    

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "adversarygate": {
    "command": "uvx",
    "args": ["adversary-gate-mcp"]
  }
}
```

## Documentation

## What AdversaryGate does

AdversaryGate is a fail-closed verification gate for Python repositories using pytest. It evaluates an agent's working-tree changes against a Git baseline and produces one of three outcomes: MERGE, BLOCK, or INCONCLUSIVE. MERGE indicates that the configured checks cleared and permits human review; it is not a release approval. BLOCK indicates that the code or its verification evidence failed. INCONCLUSIVE means that a required measurement was not established.

The gate considers more than whether the test suite exits successfully. It evaluates claims, checks coverage of changed lines, examines the strength of the test evidence, and mutation-tests the lines changed by the patch. Tests rewritten by the patch are judged using the baseline version as the oracle. Nothing is committed or reverted.

## How it works

Call gate_policy before verify_repo when you need to inspect the verification contract. This read-only tool reports the configured policy floors, baseline selection, Python interpreter, operator flags, defaults, and the arguments the caller may choose. Policy values come from the server environment and cannot be changed through an MCP tool.

verify_repo accepts a repository path, optional pytest paths or node IDs, claims, and a baseline reference when the operator has not pinned one. It writes the baseline tree, compares it with the working tree, and includes uncommitted and untracked changes in the comparison. The coverage run uses the repository as its working directory; temporary gate files are removed afterward.

Claims can be supplied as pytest node IDs such as `tests/test_auth.py::test_expiry`. If claims are empty, the server can discover tests that executed changed lines when the relevant coverage contexts are available. The result includes per-claim outcomes and the oracle used, diff coverage, suite strength, a reason, next steps, and the full artefact.

## Setup and configuration

Install the Python package with:

```bash
pip install adversary-gate coverage
```

Run the MCP server in an environment where it can access the target Git repository and execute its tests. The repository should contain the agent's changes in the working tree. New files may need to be visible to Git for the diff, for example by using `git add -N`.

Operators configure policy through `ADVERSARY_GATE_POLICY`, `ADVERSARY_GATE_BASE_REF`, and `ADVERSARY_GATE_PYTHON`. The policy determines the floors and other verification settings, while the base-ref variable can pin the comparison baseline and the Python variable selects the interpreter. gate_policy reports the resulting configuration and returns an error for an invalid operator policy.

## Tools and capabilities

- `gate_policy`: Shows the active floors, baseline behavior, interpreter, operator flags, defaults, and caller controls without running tests.
- `verify_repo`: Runs the verification process and returns a merge decision with evidence and remediation steps.
- Executes the repository's pytest suite under coverage.py.
- Checks claims against the baseline and patch, including baseline copies of rewritten tests.
- Mutation-tests changed lines to assess whether the named tests detect relevant regressions.
- Includes uncommitted and untracked working-tree changes in the patch evaluation.

## Limitations and notes

Python and pytest repositories are the supported measured target. Changes in other languages are returned as INCONCLUSIVE rather than MERGE. Test execution runs repository code and can have the same side effects as running pytest directly.

Verification can take minutes. A run exceeding `timeout_seconds` returns INCONCLUSIVE, never a pass; the response identifies the limit that should be raised. Where bubblewrap is unavailable, tests run without that sandbox and retain the surrounding network and file access. The gate does not ask callers to edit existing tests, harness files, or verification floors, and changing those does not provide merge evidence.

_Full upstream README: https://allmcps.com/mcp/adversarygate/readme_

