parse_metrics
Analyze test results or security findings by parsing JUnit XML or SARIF JSON metrics files from devpipe runs.
Instructions
Parse JUnit or SARIF metrics from a devpipe run to analyze test results or security findings.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| metricsPath | Yes | Path to metrics file (JUnit XML or SARIF JSON) | |
| format | Yes | Metrics format |
Implementation Reference
- src/index.ts:486-511 (handler)Main handler for the 'parse_metrics' tool. Validates input parameters (metricsPath and format), dispatches to appropriate parser (parseJUnitMetrics or parseSARIFMetrics), and returns parsed metrics as JSON.case 'parse_metrics': { const metricsPath = args?.metricsPath as string; const format = args?.format as string; if (!metricsPath || !format) { throw new Error('metricsPath and format are required parameters'); } let metrics; if (format === 'junit') { metrics = await parseJUnitMetrics(metricsPath); } else if (format === 'sarif') { metrics = await parseSARIFMetrics(metricsPath); } else { throw new Error(`Unsupported metrics format: ${format}`); } return { content: [ { type: 'text', text: JSON.stringify(metrics, null, 2), }, ], }; }
- src/index.ts:186-204 (schema)Input schema definition for the parse_metrics tool, defining required parameters metricsPath and format (junit or sarif).{ name: 'parse_metrics', description: 'Parse JUnit or SARIF metrics from a devpipe run to analyze test results or security findings.', inputSchema: { type: 'object', properties: { metricsPath: { type: 'string', description: 'Path to metrics file (JUnit XML or SARIF JSON)', }, format: { type: 'string', enum: ['junit', 'sarif'], description: 'Metrics format', }, }, required: ['metricsPath', 'format'], }, },
- src/utils.ts:155-163 (helper)Helper function to parse JUnit XML metrics. Currently reads the file content and returns raw data with a note about needing a proper XML parser.export async function parseJUnitMetrics(metricsPath: string): Promise<any> { try { const content = await readFile(metricsPath, 'utf-8'); // Simple parsing - in production you'd use a proper XML parser return { raw: content, note: 'JUnit parsing requires XML parser' }; } catch (error) { throw new Error(`Failed to read JUnit metrics: ${error instanceof Error ? error.message : String(error)}`); } }
- src/utils.ts:168-176 (helper)Helper function to parse SARIF JSON metrics. Reads the file and parses it as JSON.export async function parseSARIFMetrics(metricsPath: string): Promise<any> { try { const content = await readFile(metricsPath, 'utf-8'); return JSON.parse(content); } catch (error) { throw new Error(`Failed to parse SARIF metrics: ${error instanceof Error ? error.message : String(error)}`); } }