get_usage_stats
Retrieve user usage statistics and plan details on the Memory Box MCP Server, enabling efficient memory storage and semantic search insights.
Instructions
Retrieve user usage statistics and plan information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1023-1068 (handler)Executes the get_usage_stats tool by fetching stats via MemoryBoxClient.getUserStats() and formatting them into a readable text response including plan info, usage, limits, and breakdown.case "get_usage_stats": { // Get usage statistics const result = await memoryBoxClient.getUserStats(); // Format the results in a user-friendly way let responseText = "Usage Statistics:\n\n"; // Add plan information responseText += `Current Plan: ${result.plan}\n`; if (result.is_legacy_user) { responseText += "Status: Legacy User (No Enforced Limits)\n\n"; } else { responseText += "Status: Standard User\n\n"; } // Add current month usage responseText += "Current Month Usage:\n"; responseText += `- Store Memory Operations: ${result.current_month_usage.store_memory_count}\n`; responseText += `- Search Memory Operations: ${result.current_month_usage.search_memory_count}\n`; responseText += `- API Calls: ${result.current_month_usage.api_call_count}\n`; responseText += `- Total Data Processed: ${formatBytes(result.current_month_usage.total_bytes_processed)}\n\n`; // Add limits if not a legacy user if (!result.is_legacy_user && result.limits) { responseText += "Plan Limits:\n"; responseText += `- Store Memory Limit: ${result.limits.store_memory_limit} operations\n`; responseText += `- Search Memory Limit: ${result.limits.search_memory_limit} operations\n`; responseText += `- API Call Limit: ${result.limits.api_call_limit} operations\n`; responseText += `- Storage Limit: ${formatBytes(result.limits.storage_limit_bytes)}\n\n`; } // Add operation breakdown if available if (result.operations_breakdown && result.operations_breakdown.length > 0) { responseText += "Operation Breakdown:\n"; result.operations_breakdown.forEach((op: any) => { responseText += `- ${op.operation}: ${op.count} operations\n`; }); } return { content: [{ type: "text", text: responseText }] }; }
- src/index.ts:764-773 (registration)Registers the get_usage_stats tool in the listTools response, providing name, description, and empty input schema.{ name: "get_usage_stats", description: "Retrieve user usage statistics and plan information", inputSchema: { type: "object", properties: { // No specific parameters needed for this operation } } },
- src/index.ts:302-322 (helper)MemoryBoxClient method that performs the actual API request to retrieve user usage statistics from /api/v2/usage.async getUserStats(): Promise<any> { try { const response = await axios.get( `${this.baseUrl}/api/v2/usage`, { headers: { "Authorization": `Bearer ${this.token}` } } ); return response.data; } catch (error) { if (axios.isAxiosError(error)) { throw new McpError( ErrorCode.InternalError, `Failed to retrieve usage statistics: ${error.response?.data?.detail || error.message}` ); } throw error; } }