# MCP (agents) — tested.dev docs

Same uncovered lines, flakes, and duration as the scorecard.

Coverage file first. Run your test runner with coverage, or `tested run`. `tested run` writes coverage even if tests fail. MCP reads that file. It does not invent coverage. Coverage is the only PR gate. Missing JUnit is a quiet miss. Node 24+.

`@tested/mcp` 0.1.3.

## Install

`npx @tested/mcp` needs `@tested/cli` on disk (or `tested` / `td` on PATH). Install both.

```
pnpm add -D @tested/cli @tested/mcp
```

If `TESTED_BIN` is unset, the server resolves `@tested/cli`, then `which tested`. Do not paste placeholder `TESTED_BIN` paths.

## Config sketch

Every tool needs `cwd`: an absolute path to a git repo. Default `base` is `origin/main`.

```json
{
  "mcpServers": {
    "tested": {
      "command": "npx",
      "args": ["-y", "@tested/mcp"],
      "env": {
        "TESTED_ALLOWED_CWDS": "/absolute/path/to/your-git-repo"
      }
    }
  }
}
```

If `@tested/mcp` is already a project dep, use `"command": "tested-mcp"` and drop `args`.

## Tools

| Tool | When |
|------|------|
| `get_uncovered_diff` | Ranges in the patch. `cwd` absolute + git. `base` defaults to `origin/main` |
| `get_coverage_summary` | Rolled-up patch/project % |
| `explain_line` | One file:line with excerpt |
| `coverage_for` | patch coverage for paths the agent touched |
| `uncovered_branches` | uncovered branches in the patch, not only lines |
| `who_covers` | which tests execute this file:line |
| `map_uncovered_to_test` | existing test file an uncovered range should land in |
| `get_flakes` | Tests tab. Intra-run flakes and failures |
| `get_failed` | name, file, message, duration, already-flaky |
| `get_performance` | Performance tab. Suite duration and slowest tests |
| `duration_delta` | suite/test duration vs main |
| `new_since_main` | new flakes, newly slow tests, files that lost coverage vs base (informational) |
| `write_and_verify` | Write a test file + re-run coverage + fresh diff |
| `check` | `tested check --json` |
| `push` | `tested push --json`. Token. Optional `junit` |
| `doctor` | `tested doctor --json` |

## Skills

| Skill | When |
|-------|------|
| `triage` | CI red → `doctor` / `get_failed` / `get_flakes` / `get_uncovered_diff` |
| `close-patch` | `get_uncovered_diff` → `map_uncovered_to_test` → `write_and_verify` → `check` |

## Security

- Restrict `TESTED_ALLOWED_CWDS` to trusted project roots
- Optional `TESTED_BIN` / `TESTED_BIN_ALLOW_PREFIX` only when you pin a real binary. No placeholders
- Do not point MCP at world-writable paths

Human setup: [Install](https://tested.dev/docs/install)
