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

已驗證STDIO僅桌面開發者工具資料與分析

概覽

AI 產生的概覽

本機 MCP 伺服器,讀取 LCOV 覆蓋率檔案,讓編碼代理檢視專案或單一檔案的覆蓋率並比較基準變化。

可以做什麼
  • 從 LCOV 檔案讀取專案整體的行與分支覆蓋率
  • 讀取指定單一檔案的行與分支覆蓋率
  • 將目前覆蓋率記錄為本次工作階段的基準
  • 比較目前覆蓋率與基準,得出提升或退步幅度
  • 支援多種標準 LCOV 格式(僅行資料、分支資料等),回傳精簡 JSON
適用情境
適合希望編碼或測試代理在改動程式碼時判斷測試覆蓋率是提升還是退步,或需要找出未覆蓋區域而不必自行解析超大 LCOV 檔案的情境。專案測試套件需已能產生 LCOV 輸出。
執行需求
以本機 stdio 程序執行,透過 npm 套件 test-coverage-mcp 安裝(通常用 npx)並寫入用戶端的 MCP 設定,需要 Node.js 與 npm。需已存在 LCOV 檔案,預設路徑為 ./coverage/lcov.info,相對路徑依目前工作目錄解析。未宣告帳號、API 金鑰或標頭。
安裝前請注意
僅讀取本機覆蓋率檔案,不索取憑證。基準存放在暫存目錄並在系統重新啟動後清除;README 指出開始記錄會覆寫其他工作階段的基準檔案,多工作階段並行時可能互相干擾。覆蓋率數據取決於 LCOV 檔案是否已透過帶覆蓋率的測試執行重新產生。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Test Coverage Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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:

  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 coveragecoverage_summary({ lcovPath: "./coverage/lcov.info" });// Returns: { linesCoveragePercentage: 87.5, branchesCoveragePercentage: 82.1 }
// Get coverage for specific filescoverage_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 baselinestart_recording({ lcovPath: "./coverage/lcov.info" });// Returns: "Recording started"
// ... agent writes code and tests ...
// Check coverage impactget_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

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

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

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 dependenciesnpm install
# Buildnpm run build
# Run tests (with coverage!)npm test
# Run linternpm run lint
# Test with MCP inspectornpm 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

來源:README.md,提交 0d1478a

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。