Skip to main content
Glama

get_usage_stats

Retrieve usage statistics for debugging and analysis, including tool usage summaries, success/failure rates, and performance metrics.

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that executes the get_usage_stats tool logic by calling usageTracker.getUsageSummary() and formatting the result.
    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
        };
      }
    }
  • The Zod input schema definition for the get_usage_stats tool (no arguments required).
    export const GetUsageStatsArgsSchema = z.object({});
  • src/server.ts:975-987 (registration)
    The tool specification registration in the ListTools handler, defining name, description, input schema, and annotations.
        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,
        },
    },
  • The dispatch case in CallToolRequest handler that invokes the getUsageStats function.
    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,
            };
        }
  • The core helper method getUsageSummary() that generates the formatted usage statistics string used by the handler.
      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}`;
      }

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/wonderwhy-er/ClaudeComputerCommander'

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