get_usage_summary
Retrieve session, daily, and weekly usage analytics to monitor Claude Code token consumption, costs, and tool patterns.
Instructions
Get comprehensive usage summary for session, today, and this week in one call
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:235-245 (handler)MCP tool handler for 'get_usage_summary' in CallToolRequestSchema. Delegates to telemetryService.getUsageSummary() and formats response with formatUsageSummary.case 'get_usage_summary': { const summary = await this.telemetryService.getUsageSummary(); return { content: [ { type: 'text', text: this.formatUsageSummary(summary), }, ], }; }
- src/telemetry-service.ts:85-101 (helper)Core logic implementation: aggregates current session, today, and weekly usage data into a UsageSummary object.async getUsageSummary(): Promise<UsageSummary> { const [currentSession, today, thisWeek] = await Promise.all([ this.getCurrentSessionUsage(), this.getTodayUsage(), this.getWeekUsage() ]); return { currentSession, today, thisWeek, period: { start: this.getStartOfWeek().toISOString(), end: new Date().toISOString() } }; }
- src/index.ts:416-426 (helper)Helper function to format the UsageSummary into a readable markdown text response.private formatUsageSummary(summary: UsageSummary): string { let result = '# Usage Summary\n\n'; result += this.formatUsageData('Current Session', summary.currentSession) + '\n\n'; result += this.formatUsageData('Today', summary.today) + '\n\n'; result += this.formatUsageData('This Week', summary.thisWeek) + '\n\n'; result += `**Period**: ${new Date(summary.period.start).toLocaleDateString()} - ${new Date(summary.period.end).toLocaleDateString()}`; return result; }
- src/index.ts:63-69 (registration)Tool registration entry in the ListToolsRequestHandler response, defining name, description, and input schema (no parameters).name: 'get_usage_summary', description: 'Get comprehensive usage summary for session, today, and this week in one call', inputSchema: { type: 'object', properties: {}, }, },
- src/types.ts:37-45 (schema)TypeScript interface defining the structure of the UsageSummary return type used by the tool.export interface UsageSummary { currentSession: UsageData; today: UsageData; thisWeek: UsageData; period: { start: string; end: string; }; }