# MCP tools

> Hosted public Atlas MCP (mcp.kavachlabs.dev/mcp) and the local kavach mcp stdio server for coding agents.

Kavach exposes two complementary MCP surfaces so coding agents can inspect both **public open-source architectures** (zero install, zero auth) and **private local services** (zero upload, deterministic replay):

## 1. Hosted Public Atlas MCP (`https://mcp.kavachlabs.dev/mcp`)

Query AST-, schema-, and replay-verified system invariants for any public GitHub repository over **Streamable HTTP** (`2025-03-26`, server card at [`/.well-known/mcp/server-card.json`](https://mcp.kavachlabs.dev/.well-known/mcp/server-card.json)):

```tabs
--- Claude Code | bash
claude mcp add --transport http kavach-atlas https://mcp.kavachlabs.dev/mcp
--- Codex | bash
codex mcp add kavach-atlas --url https://mcp.kavachlabs.dev/mcp
--- Cursor | json title="~/.cursor/mcp.json"
{
  "mcpServers": {
    "kavach-atlas": {
      "url": "https://mcp.kavachlabs.dev/mcp"
    }
  }
}
--- VS Code | json title=".vscode/mcp.json"
{
  "servers": {
    "kavach-atlas": {
      "type": "http",
      "url": "https://mcp.kavachlabs.dev/mcp"
    }
  }
}
--- Antigravity | json title="~/.gemini/config/mcp_config.json"
{
  "mcpServers": {
    "kavach-atlas": {
      "serverUrl": "https://mcp.kavachlabs.dev/mcp"
    }
  }
}
```

Or run `kavach install-mcp --atlas` to configure `.mcp.json`, `claude`, `cursor`, `vscode`, or `antigravity` automatically.

| Tool | Arguments | Returns |
| --- | --- | --- |
| `atlas_list_invariants` | `repo` (`owner/repo` or GitHub URL), `service` (optional subpath) | Detected stateful drivers, monorepo services, proof tier, and extracted invariants with `proof_state` (`verified`, `implied`, `enforced`) and GitHub `#L` links. |
| `atlas_trace_invariant` | `repo`, `invariant_id`, `service` (optional) | Exact causal subgraph (`Entry -> Handler -> State/Gateway -> Sink -> Invariant`), guided flow steps, and bounded source excerpts. |
| `atlas_export_contract` | `repo`, `invariant_ids` (optional array), `service` (optional) | Executable `.kavach/invariants.yaml` contract, 6-line driver-wrap snippet, and starter agent setup prompt. |

---

## 2. Local `kavach mcp` (Private Repos & Deterministic Replay)

`kavach mcp` runs locally on stdin and stdout with **zero source upload**. It returns the same verdicts as the CLI as structured JSON, plus the same three `atlas_*` tools for local repositories.

```bash
claude mcp add kavach -- kavach mcp
```

For other clients, see [Use Kavach with AI agents](https://www.thekavachlabs.com/docs/guides/ai-agents#register-the-mcp-server). Tools that take a host command (`bin`, `old`, `new`) accept the same strings as the CLI; `bin` defaults to `$KAVACH_BIN`.

| Tool | Arguments | Returns |
| --- | --- | --- |
| `kavach_list_incidents` | `dir` (default: working directory) | Every `*.kavach` under it, with the recorded failure's kind, seq and message. |
| `kavach_replay` | `fixture`, `bin`, `invariants`, `rebase_timestamps`, `include_steps` | `verdict`, `passed`, `detail`, `recorded_failure`, `warnings`. |
| `kavach_time_travel` | `fixture`, `bin`, `until`, `probes`, `include_steps` | `verdict`, `passed`, `until`, `held_at_seq`, and `probes` with each probe's outcome and outputs. |
| `kavach_diff` | `fixture`, `old`, `new`, `invariants`, `variants` (default 10), `regressions` (default 48; 0 skips), `without`, `strict_effect_order`, `rebase_timestamps`, `keep` | `verdict`, `passed`, old and new replays, `variants`, and `regressions`. |
| `kavach_contract_show` | `dir` (default `./contract`) | The contract, every input with feature steps marked, and the lock. |
| `kavach_contract_check` | `dir`, `new`, `old`, `no_variants`, `strict_effect_order`, `rebase_timestamps` | `verdict`, `passed`, and `report`: changed and unreached steps, variant failures, `round` and `streak`. |
| `kavach_map` | `spec`, `fixtures`, `bin`, `new`, `diffs`, `overlays`, `out`, `max_data`, `title`, `include_model` | A lean map summary (`nodes`, `edges`, `flows`, per-fixture `runs` and `first_failure`, `stats`), plus `out_path` and `html_bytes` when `out` is set, or the full model with `include_model: true`. |
| `kavach_explore` | `fixtures`, `bin`, `invariants`, `known_findings`, `budget`, `seed`, `without`, `rebase_timestamps`, `out`, `no_shrink`, `shrink_fields` | Proactive gateway, `schrodinger`, `batch_commit_advance`, clock-jump, and redelivery fault exploration with ddmin-shrunk capsules. |
| `kavach_shrink` | `fixture`, `bin`, `invariants`, `out`, `shrink_fields`, `rebase_timestamps` | Minimized `.kavach` capsule (`ddmin`) and step/record reduction counts. |
| `kavach_rules_check` | `fixtures`, `bin`, `invariants`, `mutate`, `strict_vacuous` | Per-rule vacuity status (`holds`, `vacuous`, `violated`) and synthetic mutation catch rates. |
| `atlas_list_invariants` | `dir` (default `.`), `subpath` | Local equivalent of the hosted Atlas listing (`0` source upload). |
| `atlas_trace_invariant` | `invariant_id`, `dir`, `subpath` | Local causal subgraph and bounded source excerpts. |
| `atlas_export_contract` | `invariant_ids`, `dir`, `subpath` | Local `.kavach/invariants.yaml` contract and driver-wrap snippet. |

There is **no tool to approve a contract**: a person does that with `kavach contract approve`.

A verdict that is not a pass is a normal tool result. `isError` is set only when a tool could not run: a missing file, or a host command that does not start as a host.

## Typical agent loop

1. `kavach_list_incidents` to find fixtures.
2. `kavach_replay` on the current build; expect `still_failing@N`. Stop if it does not reproduce.
3. `kavach_time_travel` with `until` just before `N` to probe state.
4. Edit the code, build, then `kavach_diff`. Repeat until `verdict` is `fixed`.

Source: https://www.thekavachlabs.com/docs/reference/mcp
