upload_local_coverage
Upload local coverage + current source and get back what's still untested — the core self-correction loop for writing tests without waiting on CI. Works for Python (pytest-cov) and TypeScript/JavaScript (vitest + Istanbul).
coverage_kind selects the dimension: "unit" (default) is the
test-suite coverage flow described here; "browser" records an
independent per-function browser-session dimension from a real browser
run — any coverage format (Istanbul for a frontend harvest, pytest-cov
for a coverage-instrumented backend serving the browser's requests), no
junit. A branch's browser coverage is the union of what each
producer last reached — its wrapped suite, and each recorded test's
latest replay — and this upload replaces only the contribution of the
producer it belongs to, per language (a TS-only browser upload never
zeroes the Python dimension, and vice versa). It surfaces as
browser_state
(exercised/partial/unexercised) + browser_line_coverage_pct
on each function and as the unexercised_browser gap in
check_done, and never changes unit state.
Browser and manual uploads are also recorded in the branch's session
ledger, so the Tests page can say what produced them. Pass
session_id if you opened one; otherwise this upload becomes its own
session, attributed to agent — you.
Run your tests with coverage locally first:
Python:
pytest --cov --cov-branch --cov-context=testthencoverage json --show-contexts -o coverage.json(pytest-cov's own--cov-report=jsondrops the per-test contexts)TS/JS:
vitest run --coverage --coverage.provider=istanbul --coverage.reporter=json→coverage/coverage-final.json
Pass a files map of {source_path: contents} for the files under
test, plus exactly one of:
coverage_json— a single parsed report (pytest-cov or Istanbul).coverage_reports— a list of parsed reports, merged with same-file-later-wins; use this to send both a pytest-cov and a vitest report in one upload for a mixed-language repo.
IMPORTANT: the keys of files must exactly match the file paths the
coverage report records (relative to the directory the tests ran from).
If they don't, nothing matches and functions_matched comes back 0.
Stored and returned paths are always repo-rooted. If your tests ran
from a subdirectory of the repo (a monorepo package), pass
path_prefix — the repo-root-relative directory the tests ran from
(e.g. "backend"; "" if they ran at the repo root). Omit it and
the server resolves the prefix against the repo tree best-effort, else
stores paths as sent. All reports in one call share one root — split a
multi-root upload into one call per root.
functions_matched and the untested/partial lists count whole
functions only; React sub-units matched by the same upload are reported
separately as units_matched, so those numbers stay comparable
across uploads and against a repo's own sense of its size.
Uploads are merged per language, so a TS upload never wipes a branch's
Python coverage (functions_preserved reports how many rows were
kept). Upserts a single local analysis per branch, kept separate from
any CI run. Returns the coverage summary plus the untested/partial
functions and failing tests so you can fix them directly; the function
ids work with get_function_detail and get_generated_prompt.
repository_id is the GitHub owner/repo (a repo UUID also
works) — the same reference every other tool here takes.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"repository_id": "<repository_id>",
"branch": "<branch>",
"files": "<files>"
},
"name": "upload_local_coverage"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | Yes | ||
| branch | Yes | ||
| junit_xml | No | ||
| commit_sha | No | ||
| session_id | No | ||
| path_prefix | No | ||
| coverage_json | No | ||
| coverage_kind | No | unit | |
| repository_id | Yes | ||
| coverage_reports | No |