{
  "markdown": "# Test Coverage MCP\n\n[![npm version](https://badge.fury.io/js/test-coverage-mcp.svg)](https://www.npmjs.com/package/test-coverage-mcp)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n![Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen)\n![CI](https://github.com/goldbergyoni/test-coverage-mcp/actions/workflows/test.yml/badge.svg)\n![Last Commit](https://img.shields.io/github/last-commit/goldbergyoni/test-coverage-mcp)\n\n**Make your agents coverage-aware as they code for you**\n\n> “Hey, I’m a coding agent. I just created flashy nifty feature… but oops, I downgraded the coverage 🤓. How could I know that?”\n\n> “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?😳”\n\nGive your coding and testing agent eyes: MCP server that provides instant, reliable, token-efficient test coverage data for any programming language (LCOV based)\n\n__\n\n> 🚀 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\n\n## The Problem\n\nWhen AI coding agents work on your code without proper coverage tooling, they face three critical issues:\n\n1. **Coverage Blindness** - They can't see if their changes improved or regressed test coverage\n2. **Token Waste** - They burn thousands of tokens trying to parse massive LCOV files (some exceed 10 MB)\n3. **Unreliable Scripts** - They improvise custom parsing scripts that often fail or produce incorrect results\n\n## The Solution\n\nThis MCP server solves all three problems by providing:\n\n- **Coverage Awareness** - Agents can check coverage anytime with a simple tool call\n- **Token Efficiency** - Get coverage summaries in <100 tokens instead of thousands\n- **Accuracy** - Production-grade LCOV parsing that handles all format variations\n- **Baseline Tracking** - Measure coverage progress within a session without keeping state in memory\n\n**Test Coverage**: This project maintains 95% test coverage and we're targeting 100% soon.\n\n## Two Main Workflows\n\n### 1. Query Coverage Summary\n\nAsk for overall project coverage or coverage for specific files:\n\n```typescript\n// Get overall project coverage\ncoverage_summary({ lcovPath: \"./coverage/lcov.info\" });\n// Returns: { linesCoveragePercentage: 87.5, branchesCoveragePercentage: 82.1 }\n\n// Get coverage for specific files\ncoverage_file_summary({\n  lcovPath: \"./coverage/lcov.info\",\n  filePath: \"src/utils/parser.ts\",\n});\n// Returns: { path: \"src/utils/parser.ts\", linesCoveragePercentage: 92.0, branchesCoveragePercentage: 88.5 }\n```\n\n### 2. Baseline Tracking for Session Progress\n\nEstablish a baseline at session start, then measure your progress:\n\n```typescript\n// At session start - record current coverage as baseline\nstart_recording({ lcovPath: \"./coverage/lcov.info\" });\n// Returns: \"Recording started\"\n\n// ... agent writes code and tests ...\n\n// Check coverage impact\nget_diff_since_start({ lcovPath: \"./coverage/lcov.info\" });\n// Returns: { linesPercentageImpact: +2.3, branchesPercentageImpact: +1.8 }\n```\n\n**Why baseline tracking?** Without it, agents would need to keep initial coverage in their stateful memory throughout the session, consuming valuable context window space.\n\n## Installation\n\n```bash\nnpm install -g test-coverage-mcp\n```\n\n## Configuration\n\nAdd this MCP server to your AI coding tool's configuration:\n\n### Claude Desktop (Claude Code)\n\n**macOS**: Edit `~/Library/Application Support/Claude/claude_desktop_config.json`\n**Windows**: Edit `%APPDATA%\\Claude\\claude_desktop_config.json`\n\n```json\n{\n  \"mcpServers\": {\n    \"test-coverage\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"test-coverage-mcp\"]\n    }\n  }\n}\n```\n\nAfter updating, restart Claude Desktop.\n\n### Cursor IDE\n\nCreate or edit `.cursor/mcp.json` in your project root:\n\n```json\n{\n  \"mcpServers\": {\n    \"test-coverage\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"test-coverage-mcp\"]\n    }\n  }\n}\n```\n\n### GitHub Copilot (VS Code)\n\nCreate or edit `.vscode/mcp.json` in your workspace:\n\n```json\n{\n  \"servers\": {\n    \"test-coverage\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"test-coverage-mcp\"]\n    }\n  }\n}\n```\n\nRequires VS Code 1.99+ or Visual Studio 17.14+. Enterprise users need \"MCP servers in Copilot\" policy enabled.\n\n### Windsurf (Codeium IDE)\n\n**macOS**: Edit `~/.codeium/windsurf/mcp_config.json`\n**Windows**: Edit `%APPDATA%\\Codeium\\Windsurf\\mcp_config.json`\n**Linux**: Edit `~/.codeium/windsurf/mcp_config.json`\n\n```json\n{\n  \"mcpServers\": {\n    \"test-coverage\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"test-coverage-mcp\"]\n    }\n  }\n}\n```\n\nOr use the GUI: Settings → Advanced Settings → Cascade → Add Server\n\n## Available Tools\n\n### `coverage_summary`\n\nGet overall project coverage from an LCOV file.\n\n**Input:**\n\n```typescript\n{\n  lcovPath?: string  // Optional. Defaults to \"./coverage/lcov.info\"\n}\n```\n\n**Output:**\n\n```typescript\n{\n  linesCoveragePercentage: number,      // 0-100\n  branchesCoveragePercentage: number    // 0-100\n}\n```\n\n**Example:**\n\n```typescript\ncoverage_summary({ lcovPath: \"./coverage/lcov.info\" });\n// { linesCoveragePercentage: 87.5, branchesCoveragePercentage: 82.1 }\n```\n\n### `coverage_file_summary`\n\nGet coverage for a specific file.\n\n**Input:**\n\n```typescript\n{\n  lcovPath?: string,  // Optional. Defaults to \"./coverage/lcov.info\"\n  filePath: string    // Required. Path to the file\n}\n```\n\n**Output:**\n\n```typescript\n{\n  path: string,\n  linesCoveragePercentage: number,      // 0-100\n  branchesCoveragePercentage: number    // 0-100\n}\n```\n\n**Example:**\n\n```typescript\ncoverage_file_summary({\n  lcovPath: \"./coverage/lcov.info\",\n  filePath: \"src/utils/parser.ts\",\n});\n// { path: \"src/utils/parser.ts\", linesCoveragePercentage: 92.0, branchesCoveragePercentage: 88.5 }\n```\n\n### `start_recording`\n\nRecord current coverage as a baseline for later comparison.\n\n**Input:**\n\n```typescript\n{\n  lcovPath: string; // Required. Path to LCOV file to record\n}\n```\n\n**Output:**\n\n```typescript\n\"Recording started\";\n```\n\n**Example:**\n\n```typescript\nstart_recording({ lcovPath: \"./coverage/lcov.info\" });\n// \"Recording started\"\n```\n\n### `get_diff_since_start`\n\nCompare current coverage against the recorded baseline.\n\n**Input:**\n\n```typescript\n{\n  lcovPath: string; // Required. Path to current LCOV file\n}\n```\n\n**Output:**\n\n```typescript\n{\n  linesPercentageImpact: number,      // Positive = improvement, negative = regression\n  branchesPercentageImpact: number    // Positive = improvement, negative = regression\n}\n```\n\n**Example:**\n\n```typescript\nget_diff_since_start({ lcovPath: \"./coverage/lcov.info\" });\n// { linesPercentageImpact: +2.3, branchesPercentageImpact: +1.8 }\n```\n\n## Usage Examples\n\n### Example 1: Check Coverage Before Starting Work\n\n```\nAgent: \"Let me check the current test coverage before I start working\"\n[Uses coverage_summary tool]\nAgent: \"Current coverage is 87.5% lines and 82.1% branches. I'll aim to maintain or improve this.\"\n```\n\n### Example 2: Track Coverage Impact During Development\n\n```\nAgent: \"I'll record the baseline coverage first\"\n[Uses start_recording tool]\n\nAgent: \"Now I'll add the new authentication feature with tests\"\n[Writes code and tests]\n\nAgent: \"Let me check the coverage impact\"\n[Uses get_diff_since_start tool]\nAgent: \"Great! Coverage increased by 2.3% for lines and 1.8% for branches.\"\n```\n\n### Example 3: Verify Specific File Coverage\n\n```\nAgent: \"Let me check coverage for the file I just modified\"\n[Uses coverage_file_summary with filePath: \"src/auth/validator.ts\"]\nAgent: \"The validator.ts file now has 95% line coverage and 92% branch coverage.\"\n```\n\n## How It Works\n\nThis MCP server:\n\n1. **Parses LCOV files** using a production-grade parser that handles all LCOV format variations\n2. **Calculates coverage** percentages for overall project or individual files\n3. **Stores baselines** in a temporary directory for session-based tracking\n4. **Returns compact JSON** responses that consume minimal tokens\n\n## LCOV Format Support\n\nThis server supports all standard LCOV file formats, including:\n\n- Files with summary sections (`SF:`, `end_of_record`)\n- Files with line-by-line data only (`DA:` entries)\n- Files with branch coverage data (`BRDA:`, `BRF:`, `BRH:`)\n- Mixed formats within the same file\n\n## Troubleshooting\n\n### \"LCOV file not found\"\n\n- Ensure you've run your test suite with coverage enabled first\n- Check that the path to your LCOV file is correct (relative paths are resolved from current working directory)\n- Default path is `./coverage/lcov.info`\n\n### \"No coverage data found for file\"\n\n- Verify the file path matches exactly as it appears in the LCOV file\n- Some test frameworks use absolute paths, others use relative paths\n\n### \"No baseline recording found\"\n\n- You must call `start_recording` before calling `get_diff_since_start`\n- Baselines are stored in temporary storage and cleared when the system restarts\n\n## Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Build\nnpm run build\n\n# Run tests (with coverage!)\nnpm test\n\n# Run linter\nnpm run lint\n\n# Test with MCP inspector\nnpm run inspect\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT © Yoni Goldberg\n\n## Links\n\n- [GitHub Repository](https://github.com/goldbergyoni/test-coverage-mcp)\n- [npm Package](https://www.npmjs.com/package/test-coverage-mcp)\n- [MCP Documentation](https://modelcontextprotocol.io)\n- [Report Issues](https://github.com/goldbergyoni/test-coverage-mcp/issues)\n\n## Improvement ideas\n\n- coverage_file_summary returns nested properties also declared as flat\n- Start recording overrides other sessions files\n- Improve record naming - setSessionBaseline, getDiffSinceBaseline\n-\n",
  "bytes": 9786,
  "sha": "c8eb2be34ebe7889764f5dca0ddb26818627e118d664afef2680635a0f673a03",
  "repo_slug": "goldbergyoni/test-coverage-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_goldbergyoni_test_coverage_mcp_7fc57d88/readme"
}