Skip to main content
Glama

get_usage_analytics

Read-onlyIdempotent

Retrieve usage analytics and statistics for the Hi-AI MCP server, including memory usage, category distribution, time-based patterns, and graph relationships.

Instructions

도구 사용 분석 및 통계를 조회합니다.

키워드: 분석, 통계, 사용량, analytics, statistics, usage

제공 정보:

  • 메모리 사용 통계

  • 카테고리별 분포

  • 시간별 사용 패턴

  • 그래프 관계 통계

사용 예시:

  • "사용 통계 보여줘"

  • "메모리 분석"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNo분석 유형
timeRangeNo시간 범위
detailedNo상세 정보 포함 여부 (기본값: false)

Implementation Reference

  • Main handler function that orchestrates usage analytics generation using memory and graph statistics.
    export async function getUsageAnalytics(args: GetUsageAnalyticsArgs): Promise<ToolResult> {
      try {
        const { type = 'all', timeRange = 'all', detailed = false } = args;
        const memoryManager = MemoryManager.getInstance();
    
        let output = '## Hi-AI 사용 분석\n\n';
    
        // Memory statistics
        if (type === 'memory' || type === 'all') {
          output += await generateMemoryStats(memoryManager, timeRange, detailed);
        }
    
        // Graph statistics
        if (type === 'graph' || type === 'all') {
          output += await generateGraphStats(memoryManager, detailed);
        }
    
        // System info
        output += `---\n### 시스템 정보\n\n`;
        output += `- **Hi-AI 버전**: 2.0.0\n`;
        output += `- **분석 시간**: ${new Date().toLocaleString('ko-KR')}\n`;
        output += `- **시간 범위**: ${getTimeRangeLabel(timeRange)}\n`;
    
        return {
          content: [{
            type: 'text',
            text: output
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `✗ 분석 오류: ${error instanceof Error ? error.message : '알 수 없는 오류'}`
          }]
        };
      }
    }
  • ToolDefinition including input schema, description, and annotations for the get_usage_analytics tool.
    export const getUsageAnalyticsDefinition: ToolDefinition = {
      name: 'get_usage_analytics',
      description: `도구 사용 분석 및 통계를 조회합니다.
    
    키워드: 분석, 통계, 사용량, analytics, statistics, usage
    
    **제공 정보:**
    - 메모리 사용 통계
    - 카테고리별 분포
    - 시간별 사용 패턴
    - 그래프 관계 통계
    
    사용 예시:
    - "사용 통계 보여줘"
    - "메모리 분석"`,
      inputSchema: {
        type: 'object',
        properties: {
          type: {
            type: 'string',
            description: '분석 유형',
            enum: ['memory', 'graph', 'all']
          },
          timeRange: {
            type: 'string',
            description: '시간 범위',
            enum: ['1d', '7d', '30d', 'all']
          },
          detailed: {
            type: 'boolean',
            description: '상세 정보 포함 여부 (기본값: false)'
          }
        }
      },
      annotations: {
        title: 'Get Usage Analytics',
        audience: ['user', 'assistant'],
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: false
      }
    };
  • src/index.ts:143-144 (registration)
    Tool definition registered in the tools array for MCP ListTools endpoint.
    // Analytics (1) - v2.0 NEW
    getUsageAnalyticsDefinition
  • src/index.ts:210-211 (registration)
    Handler function registered in toolHandlers map for dynamic tool execution dispatch.
    // Analytics (v2.0 NEW)
    'get_usage_analytics': getUsageAnalytics
  • Helper function generating detailed memory usage statistics including category distribution, time analysis, and priority distribution.
    async function generateMemoryStats(
      memoryManager: MemoryManager,
      timeRange: string,
      detailed: boolean
    ): Promise<string> {
      const stats = memoryManager.getStats();
      const allMemories = memoryManager.list();
    
      let output = '### 메모리 통계\n\n';
      output += `- **총 메모리 수**: ${stats.total}개\n`;
      output += `- **카테고리 수**: ${Object.keys(stats.byCategory).length}개\n\n`;
    
      // Category distribution
      output += `#### 카테고리별 분포\n\n`;
      const sortedCategories = Object.entries(stats.byCategory)
        .sort((a, b) => b[1] - a[1]);
    
      for (const [category, count] of sortedCategories) {
        const percentage = ((count / stats.total) * 100).toFixed(1);
        const bar = '█'.repeat(Math.round(count / stats.total * 20));
        output += `- **${category}**: ${count}개 (${percentage}%) ${bar}\n`;
      }
      output += '\n';
    
      // Time analysis
      if (allMemories.length > 0) {
        output += `#### 시간 분석\n\n`;
    
        const now = new Date();
        const filterDate = getFilterDate(timeRange);
    
        const recentMemories = filterDate
          ? allMemories.filter(m => new Date(m.timestamp) >= filterDate)
          : allMemories;
    
        // Group by day
        const byDay: Record<string, number> = {};
        for (const memory of recentMemories) {
          const day = memory.timestamp.substring(0, 10);
          byDay[day] = (byDay[day] || 0) + 1;
        }
    
        const sortedDays = Object.entries(byDay)
          .sort((a, b) => b[0].localeCompare(a[0]))
          .slice(0, 7);
    
        if (sortedDays.length > 0) {
          output += `**최근 일별 활동**:\n`;
          for (const [day, count] of sortedDays) {
            const bar = '▓'.repeat(Math.min(count, 20));
            output += `- ${day}: ${count}개 ${bar}\n`;
          }
          output += '\n';
        }
    
        // Priority distribution
        const priorityCounts: Record<number, number> = {};
        for (const memory of allMemories) {
          const priority = memory.priority || 0;
          priorityCounts[priority] = (priorityCounts[priority] || 0) + 1;
        }
    
        if (Object.keys(priorityCounts).length > 1) {
          output += `**우선순위 분포**:\n`;
          for (const [priority, count] of Object.entries(priorityCounts).sort((a, b) => Number(b[0]) - Number(a[0]))) {
            output += `- 우선순위 ${priority}: ${count}개\n`;
          }
          output += '\n';
        }
      }
    
      // Detailed info
      if (detailed && allMemories.length > 0) {
        output += `#### 상세 정보\n\n`;
    
        // Most recently accessed
        const byAccess = [...allMemories]
          .sort((a, b) => new Date(b.lastAccessed).getTime() - new Date(a.lastAccessed).getTime())
          .slice(0, 5);
    
        output += `**최근 접근한 메모리**:\n`;
        for (const memory of byAccess) {
          output += `- \`${memory.key}\` (${formatDate(memory.lastAccessed)})\n`;
        }
        output += '\n';
    
        // Oldest memories
        const oldest = [...allMemories]
          .sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime())
          .slice(0, 5);
    
        output += `**가장 오래된 메모리**:\n`;
        for (const memory of oldest) {
          output += `- \`${memory.key}\` (${formatDate(memory.timestamp)})\n`;
        }
        output += '\n';
      }
    
      return output;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already provide strong behavioral hints (readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false), indicating this is a safe, read-only operation. The description adds value by specifying the types of analytics returned (memory usage, category distribution, time patterns, graph statistics), which gives context beyond the annotations. It doesn't disclose rate limits or auth needs, but with annotations covering safety, this is acceptable.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is moderately concise but has structural issues. It starts with a clear purpose statement, but includes a redundant 'Keywords' section that repeats terms already in the description. The bulleted list of provided information is useful, but the usage examples could be integrated more smoothly. It's front-loaded with the purpose, but some sentences (like the keyword list) don't earn their place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema), the description is reasonably complete. It explains what analytics are returned, supported by annotations that clarify behavioral traits. However, it doesn't detail the output format or structure, which would be helpful since there's no output schema. For a read-only analytics tool, it covers most essentials but leaves some ambiguity about result presentation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for all parameters (type, timeRange, detailed) including enums and defaults. The description doesn't add any parameter-specific information beyond what's in the schema, such as explaining the 'all' type or timeRange options. However, with high schema coverage, the baseline is 3, as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'retrieving usage analysis and statistics' in Korean, with English keywords reinforcing this. It lists specific types of information provided (memory usage, category distribution, time patterns, graph statistics), making the purpose concrete. However, it doesn't explicitly differentiate from sibling tools like 'analyze_complexity' or 'get_memory_graph', which appear related but have different scopes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides usage examples in Korean ('show usage statistics', 'memory analysis'), which give some implied context for when to use the tool. However, it lacks explicit guidance on when to choose this tool over alternatives like 'analyze_complexity' or 'get_memory_graph', and doesn't mention prerequisites or exclusions. The examples are helpful but insufficient for clear differentiation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/su-record/hi-ai'

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