Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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), }, ], }; } );
  • 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, }; }
  • 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); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kpanuragh/xdebug-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server