Skip to main content
Glama

get_usage_stats

Retrieve usage statistics for debugging and analysis. Provides tool usage summaries, success/failure rates, and performance metrics to monitor system operations.

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 handler function that implements the core logic of the get_usage_stats tool. It retrieves usage summary from the tracker and returns it formatted as ServerResult, handling errors gracefully.
    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 }; } }
  • Zod schema for input arguments of get_usage_stats tool (empty object since no arguments required).
    export const GetUsageStatsArgsSchema = z.object({});
  • src/server.ts:934-946 (registration)
    Tool registration in the ListToolsRequest handler: defines the tool name, description, input schema, and annotations for the MCP tools list.
    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, }, },
  • Tool execution handler in the CallToolRequest switch statement: calls the getUsageStats function directly (no args parsing needed) 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, }; }
  • Supporting utility method in usageTracker that generates the formatted usage summary string returned by the tool.
    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