get_usage_stats
Retrieve usage statistics, including success rates and performance metrics, for debugging and analysis in the Claude Desktop Commander MCP server.
Instructions
Get usage statistics for debugging and analysis.
Returns summary of tool usage, success/failure rates, and performance metrics.
This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/usage.ts:7-26 (handler)Main handler function getUsageStats that calls usageTracker.getUsageSummary() and formats the response as MCP ServerResult.export async function getUsageStats(): Promise<ServerResult> { try { const summary = await usageTracker.getUsageSummary(); return { content: [{ type: "text", text: summary }] }; } catch (error) { return { content: [{ type: "text", text: `Error retrieving usage stats: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/tools/schemas.ts:137-137 (schema)Zod schema defining empty input arguments for the tool.export const GetUsageStatsArgsSchema = z.object({});
- src/server.ts:934-946 (registration)Tool registration in listTools handler: defines name, description, inputSchema from GetUsageStatsArgsSchema.name: "get_usage_stats", description: ` Get usage statistics for debugging and analysis. Returns summary of tool usage, success/failure rates, and performance metrics. ${CMD_PREFIX_DESCRIPTION}`, inputSchema: zodToJsonSchema(GetUsageStatsArgsSchema), annotations: { title: "Get Usage Statistics", readOnlyHint: true, }, },
- src/server.ts:1122-1131 (registration)Dispatch handler in callToolRequest: invokes getUsageStats() and handles errors.case "get_usage_stats": try { result = await getUsageStats(); } catch (error) { capture('server_request_error', { message: `Error in get_usage_stats handler: ${error}` }); result = { content: [{ type: "text", text: `Error: Failed to get usage statistics` }], isError: true, }; }
- src/utils/usageTracker.ts:365-396 (helper)Helper method getUsageSummary in UsageTracker class that computes and formats the usage statistics summary string.async getUsageSummary(): Promise<string> { const stats = await this.getStats(); const now = Date.now(); const daysSinceFirst = Math.round((now - stats.firstUsed) / (1000 * 60 * 60 * 24)); const uniqueTools = Object.keys(stats.toolCounts).length; const successRate = stats.totalToolCalls > 0 ? Math.round((stats.successfulCalls / stats.totalToolCalls) * 100) : 0; const topTools = Object.entries(stats.toolCounts) .sort(([,a], [,b]) => b - a) .slice(0, 5) .map(([tool, count]) => `${tool}: ${count}`) .join(', '); return `📊 **Usage Summary** • Total calls: ${stats.totalToolCalls} (${stats.successfulCalls} successful, ${stats.failedCalls} failed) • Success rate: ${successRate}% • Days using: ${daysSinceFirst} • Sessions: ${stats.totalSessions} • Unique tools: ${uniqueTools} • Most used: ${topTools || 'None'} • Feedback given: ${(await configManager.getValue('feedbackGiven')) ? 'Yes' : 'No'} **By Category:** • Filesystem: ${stats.filesystemOperations} • Terminal: ${stats.terminalOperations} • Editing: ${stats.editOperations} • Search: ${stats.searchOperations} • Config: ${stats.configOperations} • Process: ${stats.processOperations}`; }