
Coverctl
io.github.klarlabs-studio由 GitHub 账号 klarlabs-studio 发布v1.20.0更新于 Oct 24, 2026
Go code coverage analysis tool with MCP server for AI-powered coverage workflows
概览
本地 MCP 服务器,运行项目原生测试覆盖率并按域执行覆盖率阈值,让 AI 编码代理在提交前检查覆盖率策略
- 可以做什么
- 运行带覆盖率的测试并执行配置的策略,返回各域的通过/失败、文件与警告(check)。推荐覆盖率阈值,并按域对覆盖率欠账排序,帮助代理决定投入方向(suggest、debt)。只读资源提供覆盖率欠账、已记录趋势、阈值建议和检测到的项目配置。CI 模式下还有初始化配置、分析已有覆盖率报告、记录历史、比较两份报告、生成 SVG 徽章以及向拉取请求发布报告的工具。
- 适用场景
- 适用于 AI 编码代理在有覆盖率要求的代码库中修改代码,并希望在同一会话内而非 CI 失败后才发现回归的场景。也适合用一份配置对多种语言仓库按域执行最低覆盖率的项目。
- 运行要求
- 以本地进程通过 stdio 运行,从对应平台的安装包安装(macOS、Linux、Windows)。需要项目自身的语言工具链和覆盖率运行器,以及仓库中的 .coverctl.yaml 策略文件。未声明账号、API 密钥或环境变量;可用首次运行的诊断命令验证安装。
安装
在 SourceWeft 中
- 打开 控制台中的 Coverctl,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
coverctl
Agent-loop coverage governance for all sorts of languages — coverage your AI coding agent calls before commit, not a dashboard you read after CI.
Works with Python, TypeScript/JavaScript, Java, Rust, Go, C#, C/C++, PHP, Ruby, Swift, Dart, Scala, Elixir, and Shell — one .coverctl.yaml, one MCP surface. Not a Go cover tool.
Get started ↓ · Languages ↓ · What it looks like ↓ · MCP tools ↓ · CLI reference ↓ · Why this exists ↓ · Community ↓
[MCP] [15 languages] [Releases]
"Our AI agents ship code fast, but they're blind to coverage policy while editing. We only see breakage in CI, after context is gone, and the same agent then guesses its way to a fix."
Same policy model on every language: auto-detect the runner, group paths into domains, enforce mins before commit. Mock-heavy or exotic layouts may need an explicit domains: block in .coverctl.yaml.
coverctl is not a Go cover CLI: it is policy + MCP over each language's native coverage runner (vs go test -cover / pytest --cov).
Get started
Wire into Claude Code (~/.config/claude-code/mcp.json):
Ask the agent: "Run coverctl check and tell me which domains regressed."
For Cursor / Cline / Claude Desktop / Aider / Continue / OpenCode and other MCP clients, see docs/src/content/docs/mcp.mdx. All MCP-capable clients work; coverctl mcp serve runs in agent mode by default (3 tools: check, suggest, debt). Use --mode=ci for the full nine-tool surface.
Validate the install end-to-end:
What it looks like in the agent loop
Rendered for clarity — your client may format tool-calls differently.
The regression that used to surface in CI 8 minutes later is fixed in the same agent turn.
The agent does well: reads check output verbatim, calls suggest to find uncovered files, calls debt to rank smallest fixes, re-runs check to confirm.
Watch for: agents lowering thresholds in .coverctl.yaml to "fix" a failure (it's not a fix). Agents claiming coverage rose without a new check call (hallucination). Agents ignoring rejection error_code and retrying with the same input.
coverctl returns deterministic structured signals; the agent's fix still needs a human reading. The full contract is in docs/src/content/docs/mcp.mdx.
Why this exists
AI coding agents write code blind to coverage. They edit, you commit, the regression surfaces in CI minutes or hours later — too late to course-correct in the same session. Dashboards (Codecov, Coveralls) and raw language runners (go test -cover, pytest --cov, nyc) target humans reading numbers after the fact — not agents enforcing policy mid-edit.
coverctl is built for the agent loop (and is not a replacement for Go's cover tooling):
- Catches regressions before commit. Coverage feedback in the agent's edit turn — not minutes after CI fails. The wedge metric is regressions caught pre-commit.
- Agent-callable via MCP. Speaks MCP — the multi-vendor agent-tool standard now governed by Anthropic, OpenAI, Google, Microsoft, AWS. Works with every MCP-capable client today; works with whatever ships next without modification.
- Polyglot governance, one config. One
.coverctl.yamlenforces per-domain thresholds across 15 languages. On Go repos it may invokego testthe way it invokespytestelsewhere — then applies the same domain policy. Agents touch any language; coverage governance must too. - Local-first. Your source never leaves the machine. Agent calls coverctl over stdio, not over a SaaS API. No account, no upload, no third-party dependency in the agent's reach.
- Hardened MCP surface. Input + output sanitization defends against prompt-injection through test-runner flags and hostile filenames in coverage profiles (Lethal Trifecta).
The CLI and MCP server are Apache-2.0 licensed and stay free. A hosted layer for cross-repo coverage history is on the roadmap (see docs/strategy/monetization-decision.md) — additive, not a paywall.
MCP tools
Agent mode advertises three tools (check, suggest, debt) for reliable agent tool selection. CI mode (--mode=ci) adds the rest.
MCP resources (read-only context)
Security boundaries
coverctl treats MCP traffic as untrusted in both directions, per the Lethal Trifecta threat model.
- Input boundary. Agent mode accepts typed capabilities (
packages,tags,race,short,run,timeout) and rejects arbitrary runnertestArgsso coverctl cannot be used as a generic command-execution MCP server. Dangerous flags (--rootdir,--cov-config,-D,-I,--require,--init-script,--node-options, ...) are also denied as defense in depth. Agent mode cannot select an alternate policy file, filter check to a subset of domains, narrowcoverageScope(shrinking measurement can hide untested domains), skip the test run viafromProfile, or use incremental check (an empty diff auto-passes); repository.coverctl.yamlis authoritative and verification must execute tests against the full policy. Rejection responses use a stable schema witherror_codeand agent-actionableremediation. CLI invocations from a human terminal are not sanitized; the human is the trust boundary there. - Output boundary. User-controlled identifiers flowing back to the agent (filenames in coverage profiles, domain names, package paths) are percent-encoded rather than destructively replaced, so distinct names stay distinct (
src/über.godoes not collapse into another file). Control characters, backticks, and markdown metacharacters cannot render as instructions. Prevents return-trip prompt injection through a hostile PR or attacker-named test file.
coverctl is local-first. The default install transmits nothing — no telemetry, no analytics, no source data. An opt-in --mcp-telemetry flag emits structured tool-call events to stderr for users who want to instrument their own pipelines (format documented in docs/design/mcp-metrics-spec.md). Adversarial + happy-path evals (85+ scenarios under internal/eval/scenarios/) gate every release on rejection-schema integrity and prompt-injection resistance.
Canonical intent: docs/strategy/system-intent.md. Full threat model + residual risk: docs/security/mcp-threat-model.md.
CLI reference
The CLI is the substrate behind the MCP server; humans can use it directly.
Global flags: -q/--quiet, --no-color, --ci (combines quiet + GitHub Actions annotations).
Test-execution flags
check, run, record accept toolchain flags forwarded to the underlying test runner:
Terminal flow (without an agent)
If you prefer running coverctl directly:
If a step fails: coverctl detect --dry-run previews init output; coverctl check -o json surfaces structured failure detail; coverctl record --commit "$(git rev-parse HEAD)" --branch "$(git rev-parse --abbrev-ref HEAD)" provides metadata explicitly in CI.
Configuration
.coverctl.yaml (schema: schemas/coverctl.schema.json):
Domains are named path groups, not language packages. match uses path globs for most languages (src/auth/**) or Go package paths when the project is Go (./internal/auth/...):
Per-domain enforcement is the point: overall coverage hides regressions in critical paths. coverctl evaluates each domain against its own minimum and fails the build if any domain falls below. Per-language starters: docs quick start. How this differs from raw runners: vs native coverage.
Go-only footnote: why numbers can differ from plain go test ./...
On Go projects coverctl may pass -coverpkg spanning configured domains so a package is credited for tests of other packages that exercise it. Plain go test ./... credits only a package's own tests — two legitimate numbers; coverctl's is usually higher. This is Go runner behavior, not the product model. Prefer coverctl check profiles when comparing history. --from-profile reports whatever the supplied profile measured.
Advanced
Multi-package monorepo? Use extends: for inherited policies. Starting point: copy templates/coverctl.yaml.
Supported languages
One product across 15 languages. coverctl auto-detects which runner to call; you write path domains once.
Per-language config examples: docs quick start.
GitHub Action
For platform & devex teams
Standardizing coverage policy across many polyglot repos? coverctl ships with the artifacts your security and procurement reviews will ask for:
- MCP threat model — input + output boundary controls, prompt-injection defense, residual risks.
- Rejection schema reference — stable
error_code+remediationcontract for agent recovery. - GTM funnel metrics spec — what's instrumented and how telemetry stays opt-in.
Considering coverctl org-wide? Open a GitHub issue with label platform-evaluation — happy to walk through architecture and trust boundaries.
Community
- Claude Code Plugin Marketplace — install
coverctldirectly via/plugin install. - MCP Registry — listed at registry.modelcontextprotocol.io.
- GitHub Discussions — go.klarlabs.de/coverctl/discussions.
- Sponsor coverctl development — github.com/sponsors/felixgeelhaar.
Used coverctl for a few weeks? Run coverctl survey to share PMF feedback (local-only by default; nothing transmitted unless you opt in).
Built by Felix Geelhaar with contributions from the polyglot AI-coding community.
Contributing
- TDD: tests before behavior changes.
- Meet each domain's
minin.coverctl.yaml(default 80% when unset). This repo is Go, so dogfood withgo run ./cmd/coverctl check(policy over the runner — not a substitute for readinggo testfailures). - Conventional Commits (
feat:,fix:,chore:, ...) for Relicta version-bump logic. mainis protected; merge via PR after CI green (.github/workflows/go.yml+.github/workflows/eval.yml).- Run
gofmt -wandgolangci-lint v2before pushing.
Architecture details for contributors: ARCHITECTURE.md.
Releases
Managed by Relicta. Do not push v* tags manually.
Security
See SECURITY.md for disclosure policy. MCP-input sanitization (internal/mcp/sanitize.go) and output canonicalization (internal/mcp/sanitize_output.go) are the primary defenses against prompt-injection-driven argument and content attacks; report bypasses privately.
来源:README.md,提交 2abd070
工具
0版本历史
1- v1.20.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分