io.github.goldbergyoni/test-coverage-mcp

编码与调试

by goldbergyoni

Analyze test coverage from LCOV files - makes AI agents coverage-aware without wasting tokens

什么是 io.github.goldbergyoni/test-coverage-mcp

Analyze test coverage from LCOV files - makes AI agents coverage-aware without wasting tokens

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:

  1. Coverage Blindness - They can't see if their changes improved or regressed test coverage
  2. Token Waste - They burn thousands of tokens trying to parse massive LCOV files (some exceed 10 MB)
  3. 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:

typescript
// Get overall project coverage
coverage_summary({ lcovPath: "./coverage/lcov.info" });
// Returns: { linesCoveragePercentage: 87.5, branchesCoveragePercentage: 82.1 }

// Get coverage for specific files
coverage_file_summary({
  lcovPath: "./coverage/lcov.info",
  filePath: "src/utils/parser.ts",
});
// Returns: { path: "src/utils/parser.ts", linesCoveragePercentage: 92.0, branchesCoveragePercentage: 88.5 }

2. Baseline Tracking for Session Progress

Establish a baseline at session start, then measure your progress:

typescript
// At session start - record current coverage as baseline
start_recording({ lcovPath: "./coverage/lcov.info" });
// Returns: "Recording started"

// ... agent writes code and tests ...

// Check coverage impact
get_diff_since_start({ lcovPath: "./coverage/lcov.info" });
// Returns: { linesPercentageImpact: +2.3, branchesPercentageImpact: +1.8 }

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

bash
npm install -g test-coverage-mcp

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

json
{
  "mcpServers": {
    "test-coverage": {
      "command": "npx",
      "args": ["-y", "test-coverage-mcp"]
    }
  }
}

After updating, restart Claude Desktop.

Cursor IDE

Create or edit .cursor/mcp.json in your project root:

json
{
  "mcpServers": {
    "test-coverage": {
      "command": "npx",
      "args": ["-y", "test-coverage-mcp"]
    }
  }
}

GitHub Copilot (VS Code)

Create or edit .vscode/mcp.json in your workspace:

json
{
  "servers": {
    "test-coverage": {
      "command": "npx",
      "args": ["-y", "test-coverage-mcp"]
    }
  }
}

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

json
{
  "mcpServers": {
    "test-coverage": {
      "command": "npx",
      "args": ["-y", "test-coverage-mcp"]
    }
  }
}

Or use the GUI: Settings → Advanced Settings → Cascade → Add Server

Available Tools

coverage_summary

Get overall project coverage from an LCOV file.

Input:

typescript
{
  lcovPath?: string  // Optional. Defaults to "./coverage/lcov.info"
}

Output:

typescript
{
  linesCoveragePercentage: number,      // 0-100
  branchesCoveragePercentage: number    // 0-100
}

Example:

typescript
coverage_summary({ lcovPath: "./coverage/lcov.info" });
// { linesCoveragePercentage: 87.5, branchesCoveragePercentage: 82.1 }

coverage_file_summary

Get coverage for a specific file.

Input:

typescript
{
  lcovPath?: string,  // Optional. Defaults to "./coverage/lcov.info"
  filePath: string    // Required. Path to the file
}

Output:

typescript
{
  path: string,
  linesCoveragePercentage: number,      // 0-100
  branchesCoveragePercentage: number    // 0-100
}

Example:

typescript
coverage_file_summary({
  lcovPath: "./coverage/lcov.info",
  filePath: "src/utils/parser.ts",
});
// { path: "src/utils/parser.ts", linesCoveragePercentage: 92.0, branchesCoveragePercentage: 88.5 }

start_recording

Record current coverage as a baseline for later comparison.

Input:

typescript
{
  lcovPath: string; // Required. Path to LCOV file to record
}

Output:

typescript
"Recording started";

Example:

typescript
start_recording({ lcovPath: "./coverage/lcov.info" });
// "Recording started"

get_diff_since_start

Compare current coverage against the recorded baseline.

Input:

typescript
{
  lcovPath: string; // Required. Path to current LCOV file
}

Output:

typescript
{
  linesPercentageImpact: number,      // Positive = improvement, negative = regression
  branchesPercentageImpact: number    // Positive = improvement, negative = regression
}

Example:

typescript
get_diff_since_start({ lcovPath: "./coverage/lcov.info" });
// { linesPercentageImpact: +2.3, branchesPercentageImpact: +1.8 }

Usage Examples

Example 1: Check Coverage Before Starting Work

code
Agent: "Let me check the current test coverage before I start working"
[Uses coverage_summary tool]
Agent: "Current coverage is 87.5% lines and 82.1% branches. I'll aim to maintain or improve this."

Example 2: Track Coverage Impact During Development

code
Agent: "I'll record the baseline coverage first"
[Uses start_recording tool]

Agent: "Now I'll add the new authentication feature with tests"
[Writes code and tests]

Agent: "Let me check the coverage impact"
[Uses get_diff_since_start tool]
Agent: "Great! Coverage increased by 2.3% for lines and 1.8% for branches."

Example 3: Verify Specific File Coverage

code
Agent: "Let me check coverage for the file I just modified"
[Uses coverage_file_summary with filePath: "src/auth/validator.ts"]
Agent: "The validator.ts file now has 95% line coverage and 92% branch coverage."

How It Works

This MCP server:

  1. Parses LCOV files using a production-grade parser that handles all LCOV format variations
  2. Calculates coverage percentages for overall project or individual files
  3. Stores baselines in a temporary directory for session-based tracking
  4. 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_recording before calling get_diff_since_start
  • Baselines are stored in temporary storage and cleared when the system restarts

Development

bash
# Install dependencies
npm install

# Build
npm run build

# Run tests (with coverage!)
npm test

# Run linter
npm run lint

# Test with MCP inspector
npm run inspect

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

常见问题

io.github.goldbergyoni/test-coverage-mcp 是什么?

Analyze test coverage from LCOV files - makes AI agents coverage-aware without wasting tokens

相关 Skills

前端设计

by anthropics

Universal
热门

面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。

想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。

编码与调试
未扫描152.6k

网页应用测试

by anthropics

Universal
热门

用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。

借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。

编码与调试
未扫描152.6k

网页构建器

by anthropics

Universal
热门

面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。

在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。

编码与调试
未扫描152.6k

相关 MCP Server

GitHub

编辑精选

by GitHub

热门

GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。

这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。

编码与调试
87.4k

by Context7

热门

Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。

它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。

编码与调试
57.7k

by tldraw

热门

tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。

这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。

编码与调试
48.0k

评论