get_coverage_report
Retrieve current code coverage data to analyze which PHP code paths have been executed during debugging sessions.
Instructions
Get the current code coverage report
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/advanced.ts:477-494 (registration)Registers the MCP tool 'get_coverage_report' with no input parameters. The handler retrieves the coverage summary and top 10 hot spots using CodeCoverageTracker and returns them as formatted JSON text content.server.tool( 'get_coverage_report', 'Get the current code coverage report', {}, async () => { const summary = ctx.coverageTracker.getSummary(); const hotSpots = ctx.coverageTracker.getHotSpots(10); return { content: [ { type: 'text', text: JSON.stringify({ summary, hotSpots }, null, 2), }, ], }; } );
- src/session/code-coverage.ts:180-222 (helper)CodeCoverageTracker.getSummary() method called by the tool handler to compute overall coverage statistics including per-file summaries.getSummary(): { isTracking: boolean; duration?: number; totalFiles: number; totalLinesExecuted: number; uniqueLinesExecuted: number; filesSummary: Array<{ file: string; executedLines: number; totalLines?: number; coveragePercent?: number; }>; } { if (!this.currentReport) { return { isTracking: false, totalFiles: 0, totalLinesExecuted: 0, uniqueLinesExecuted: 0, filesSummary: [], }; } const duration = this.currentReport.endedAt ? this.currentReport.endedAt.getTime() - this.currentReport.startedAt.getTime() : Date.now() - this.currentReport.startedAt.getTime(); const filesSummary = Array.from(this.currentReport.files.values()).map((f) => ({ file: f.file, executedLines: f.executedLines.size, totalLines: f.totalLines, coveragePercent: f.coveragePercent, })); return { isTracking: this.isTracking, duration, totalFiles: this.currentReport.totalFiles, totalLinesExecuted: this.currentReport.totalLinesExecuted, uniqueLinesExecuted: this.currentReport.uniqueLinesExecuted, filesSummary, }; }
- src/session/code-coverage.ts:161-175 (helper)CodeCoverageTracker.getHotSpots() method called by the tool handler to get the top most-executed lines across all files.getHotSpots(limit: number = 10): Array<{ file: string; line: number; hitCount: number }> { if (!this.currentReport) return []; const hotSpots: Array<{ file: string; line: number; hitCount: number }> = []; for (const [file, coverage] of this.currentReport.files) { for (const [line, hitCount] of coverage.hitCounts) { hotSpots.push({ file, line, hitCount }); } } return hotSpots .sort((a, b) => b.hitCount - a.hitCount) .slice(0, limit); }