Skip to content

MCP Server (AI Agents)

coverctl ships an MCP server so AI coding agents can ask for coverage feedback inline — domain-aware policy results, debt rankings, threshold suggestions, and per-file deltas — without leaving the edit loop.

The MCP server is the canonical surface. The CLI is the substrate behind it; humans can use either.

Add to ~/.config/claude-code/mcp.json:

{
"mcpServers": {
"coverctl": {
"command": "coverctl",
"args": ["mcp", "serve"]
}
}
}

Ask the agent: “Run coverctl check and tell me which domains regressed.”

ToolPurpose
initAuto-detect project structure and create .coverctl.yaml with domain policies.
checkRun tests with coverage and enforce policy. Returns per-domain pass/fail, files, warnings.
reportAnalyze an existing coverage profile without running tests.
recordRecord current coverage to history for trend tracking.
compareDiff two coverage profiles. Returns delta, improved/regressed files, domain changes.
debtCoverage gap per domain — where to spend effort, ranked.
suggestRecommend thresholds (current / aggressive / conservative).
badgeGenerate SVG coverage badge.
pr-commentPost coverage report to GitHub / GitLab / Bitbucket PR.

Read-only context the agent can pull on demand:

URIContent
coverctl://debtCoverage debt as JSON.
coverctl://trendTrend over recorded history.
coverctl://suggestThreshold suggestions.
coverctl://configDetected project config.

Concrete defenses applied to every MCP tool call:

  • Argument sanitization. Test-runner flags that load arbitrary code are rejected: --rootdir, --cov-config, --require, --init-script, --node-options, --manifest-path, --target-dir, -D, -I, -P, and others. Shell metacharacters in arguments are rejected.
  • Path scope enforcement. Every path input (configPath, profile, historyPath, output, baseProfile, headProfile) is validated to stay within the working directory. Absolute paths, parent escapes, and symlinks that resolve outside the scope are rejected.
  • Rate limit on pr-comment. Five calls per five minutes per pull request. Stops agent loops from burning GitHub abuse quota.
  • Forensic logging. With --debug, every test-runner invocation emits a structured event with binary path, args fingerprint, exit code, and elapsed duration.

CLI invocations from a human terminal are not sanitized — the human is the trust boundary there.

Check that the agent can see the server:

Terminal window
coverctl mcp serve --help
# Should print MCP serve options without error.

Then in the agent: “What MCP tools do you have available from coverctl?” The agent should list init, check, report, etc.

Agent can’t find the binary. Use an absolute path in the command field instead of coverctl:

"command": "/opt/homebrew/bin/coverctl"

Find the path with which coverctl.

Rejected unsafe MCP input in agent output. The sanitizer blocked an argument shape associated with code execution. The error names the field and the offending value. Drop the dangerous flag or use the long-form equivalent if it has a safer cousin.

Path errors. All path inputs must be relative to the working directory. Absolute paths are rejected. Pass Profile=".cover/coverage.out" not Profile="/abs/path/coverage.out".

Rate-limit error on pr-comment. The PR was already updated five times in the last five minutes. Wait it out, or use dryRun=true to generate the comment body without posting.