get_tool_usage_breakdown
Analyze tool usage patterns and edit decisions to monitor Claude Code session activity and identify optimization opportunities.
Instructions
Get breakdown of tool usage and edit decisions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:345-355 (handler)MCP tool request handler that executes the get_tool_usage_breakdown tool by calling the telemetry service and formatting the response.case 'get_tool_usage_breakdown': { const breakdown = await this.telemetryService.getToolUsageBreakdown(); return { content: [ { type: 'text', text: this.formatToolUsageBreakdown(breakdown), }, ], }; }
- src/types.ts:69-73 (schema)TypeScript interface defining the structure of the tool's output data.export interface ToolUsageBreakdown { totalEditDecisions: number; averageDecisionsPerSession: number; peakDecisionHour: number; }
- src/index.ts:155-162 (registration)Tool registration in the MCP tools array, including name, description, and empty input schema.{ name: 'get_tool_usage_breakdown', description: 'Get breakdown of tool usage and edit decisions', inputSchema: { type: 'object', properties: {}, }, },
- src/telemetry-service.ts:161-175 (helper)Main logic for fetching and computing tool usage breakdown from Prometheus metrics.async getToolUsageBreakdown(): Promise<ToolUsageBreakdown> { const queries = { totalEditDecisions: 'sum(claude_code_code_edit_tool_decision_total)', totalSessions: 'sum(claude_code_session_count_total)' }; const results = await this.executeQueries(queries); const totalSessions = results.totalSessions || 1; return { totalEditDecisions: results.totalEditDecisions || 0, averageDecisionsPerSession: (results.totalEditDecisions || 0) / totalSessions, peakDecisionHour: 14 // Placeholder - would need hourly breakdown analysis }; }
- src/index.ts:485-490 (helper)Helper function to format the tool usage breakdown data into a markdown response.private formatToolUsageBreakdown(breakdown: ToolUsageBreakdown): string { return `## Tool Usage Breakdown\n\n` + `**Total Edit Decisions**: ${breakdown.totalEditDecisions.toLocaleString()}\n` + `**Average Decisions/Session**: ${Math.round(breakdown.averageDecisionsPerSession)}\n` + `**Peak Decision Hour**: ${breakdown.peakDecisionHour}:00`; }