
Test Coverage Mcp
io.github.goldbergyoni由 GitHub 账号 goldbergyoni 发布v1.1.0更新于 Oct 24, 2026
Analyze test coverage from LCOV files - makes AI agents coverage-aware without wasting tokens
概览
本地 MCP 服务器,读取 LCOV 覆盖率文件,让编码代理查看项目或单文件覆盖率并对比基线变化。
- 可以做什么
- 从 LCOV 文件读取项目整体行与分支覆盖率
- 读取指定单个文件的行与分支覆盖率
- 将当前覆盖率记录为本次会话的基线
- 对比当前覆盖率与基线,得出提升或回退幅度
- 兼容多种标准 LCOV 格式(仅行数据、分支数据等),返回精简 JSON
- 适用场景
- 适合希望编码或测试代理在改动代码时判断测试覆盖率是提升还是回退,或需要定位未覆盖区域而不必自行解析超大 LCOV 文件的场景。项目测试套件需已能生成 LCOV 输出。
- 运行要求
- 以本地 stdio 进程运行,通过 npm 包 test-coverage-mcp 安装(通常用 npx)并写入客户端的 MCP 配置,需要 Node.js 与 npm。需已存在 LCOV 文件,默认路径为 ./coverage/lcov.info,相对路径按当前工作目录解析。未声明账号、API 密钥或请求头。
安装
在 SourceWeft 中
- 打开 控制台中的 Test Coverage Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Test Coverage MCP
[npm version] [License: MIT] [Coverage] [CI] [Last Commit]
Make your agents coverage-aware as they code for you
“Hey, I’m a coding agent. I just created flashy nifty feature… but oops, I downgraded the coverage 🤓. How could I know that?”
“Hey, I’m a testing agent. I was tasked to cover some code with testing, but how can I find which areas are not covered?😳”
Give your coding and testing agent eyes: MCP server that provides instant, reliable, token-efficient test coverage data for any programming language (LCOV based)
__
🚀 Just launched (November 2025) ! I spend great time these days on polishing this library. If you find this valuable, a ⭐ star helps signal to other developers that this project is worth their attention
The Problem
When AI coding agents work on your code without proper coverage tooling, they face three critical issues:
- Coverage Blindness - They can't see if their changes improved or regressed test coverage
- Token Waste - They burn thousands of tokens trying to parse massive LCOV files (some exceed 10 MB)
- Unreliable Scripts - They improvise custom parsing scripts that often fail or produce incorrect results
The Solution
This MCP server solves all three problems by providing:
- Coverage Awareness - Agents can check coverage anytime with a simple tool call
- Token Efficiency - Get coverage summaries in <100 tokens instead of thousands
- Accuracy - Production-grade LCOV parsing that handles all format variations
- Baseline Tracking - Measure coverage progress within a session without keeping state in memory
Test Coverage: This project maintains 95% test coverage and we're targeting 100% soon.
Two Main Workflows
1. Query Coverage Summary
Ask for overall project coverage or coverage for specific files:
2. Baseline Tracking for Session Progress
Establish a baseline at session start, then measure your progress:
Why baseline tracking? Without it, agents would need to keep initial coverage in their stateful memory throughout the session, consuming valuable context window space.
Installation
Configuration
Add this MCP server to your AI coding tool's configuration:
Claude Desktop (Claude Code)
macOS: Edit ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: Edit %APPDATA%\Claude\claude_desktop_config.json
After updating, restart Claude Desktop.
Cursor IDE
Create or edit .cursor/mcp.json in your project root:
GitHub Copilot (VS Code)
Create or edit .vscode/mcp.json in your workspace:
Requires VS Code 1.99+ or Visual Studio 17.14+. Enterprise users need "MCP servers in Copilot" policy enabled.
Windsurf (Codeium IDE)
macOS: Edit ~/.codeium/windsurf/mcp_config.json
Windows: Edit %APPDATA%\Codeium\Windsurf\mcp_config.json
Linux: Edit ~/.codeium/windsurf/mcp_config.json
Or use the GUI: Settings → Advanced Settings → Cascade → Add Server
Available Tools
coverage_summary
Get overall project coverage from an LCOV file.
Input:
Output:
Example:
coverage_file_summary
Get coverage for a specific file.
Input:
Output:
Example:
start_recording
Record current coverage as a baseline for later comparison.
Input:
Output:
Example:
get_diff_since_start
Compare current coverage against the recorded baseline.
Input:
Output:
Example:
Usage Examples
Example 1: Check Coverage Before Starting Work
Example 2: Track Coverage Impact During Development
Example 3: Verify Specific File Coverage
How It Works
This MCP server:
- Parses LCOV files using a production-grade parser that handles all LCOV format variations
- Calculates coverage percentages for overall project or individual files
- Stores baselines in a temporary directory for session-based tracking
- Returns compact JSON responses that consume minimal tokens
LCOV Format Support
This server supports all standard LCOV file formats, including:
- Files with summary sections (
SF:,end_of_record) - Files with line-by-line data only (
DA:entries) - Files with branch coverage data (
BRDA:,BRF:,BRH:) - Mixed formats within the same file
Troubleshooting
"LCOV file not found"
- Ensure you've run your test suite with coverage enabled first
- Check that the path to your LCOV file is correct (relative paths are resolved from current working directory)
- Default path is
./coverage/lcov.info
"No coverage data found for file"
- Verify the file path matches exactly as it appears in the LCOV file
- Some test frameworks use absolute paths, others use relative paths
"No baseline recording found"
- You must call
start_recordingbefore callingget_diff_since_start - Baselines are stored in temporary storage and cleared when the system restarts
Development
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT © Yoni Goldberg
Links
Improvement ideas
- coverage_file_summary returns nested properties also declared as flat
- Start recording overrides other sessions files
- Improve record naming - setSessionBaseline, getDiffSinceBaseline
来源:README.md,提交 0d1478a
工具
0版本历史
1- v1.1.0最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。