Skip to main content
Glama
cordlesssteve

Claude Telemetry MCP

get_today_usage

Retrieve today's Claude usage metrics including tokens, cost, sessions, and activity to monitor consumption and track patterns.

Instructions

Get total usage metrics for today (tokens, cost, sessions, activity)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function that fetches today's usage metrics from Prometheus using predefined PromQL queries over the last 1 day and constructs the UsageData object.
    async getTodayUsage(): Promise<UsageData> {
      const startOfDay = this.getStartOfDay();
      const now = new Date();
      
      const queries = {
        tokens: `sum(increase(claude_code_token_usage_tokens_total[1d]))`,
        cost: `sum(increase(claude_code_cost_usage_USD_total[1d]))`,
        sessions: `sum(increase(claude_code_session_count_total[1d]))`,
        activeTime: `sum(increase(claude_code_active_time_seconds_total[1d]))`,
        linesOfCode: `sum(increase(claude_code_lines_of_code_count_total[1d]))`,
        commits: `sum(increase(claude_code_commit_count_total[1d]))`,
        editDecisions: `sum(increase(claude_code_code_edit_tool_decision_total[1d]))`
      };
    
      const results = await this.executeQueries(queries);
      return this.buildUsageData(results);
    }
  • src/index.ts:46-52 (registration)
    Tool registration in the ListTools response, defining name, description, and empty input schema.
    {
      name: 'get_today_usage',
      description: 'Get total usage metrics for today (tokens, cost, sessions, activity)',
      inputSchema: {
        type: 'object',
        properties: {},
      },
  • MCP CallToolRequest handler case that calls the telemetry service method and returns formatted text response.
    case 'get_today_usage': {
      const usage = await this.telemetryService.getTodayUsage();
      return {
        content: [
          {
            type: 'text',
            text: this.formatUsageData('Today', usage),
          },
        ],
      };
    }
  • TypeScript interface defining the structure of UsageData returned by the handler.
    export interface UsageData {
      tokens: number;
      cost: number;
      sessions: number;
      activeTime: number;
      linesOfCode: number;
      commits: number;
      editDecisions: number;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what metrics are retrieved but doesn't describe the return format, whether data is real-time or cached, permission requirements, or rate limits. For a read operation with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose ('Get total usage metrics for today') and lists specific metrics without unnecessary elaboration. Every word earns its place, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers what metrics are retrieved but lacks details on return format, data freshness, or error handling. For a read-only tool with no structured output, this is minimally viable but leaves gaps in context.

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

Parameters4/5

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

The tool has 0 parameters, and schema description coverage is 100% (since there are no parameters to describe). The description doesn't need to add parameter details, so it meets the baseline of 4 for tools with no parameters, as it focuses on the tool's purpose without redundant information.

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 verb ('Get') and resource ('total usage metrics for today') with specific metrics listed (tokens, cost, sessions, activity). It distinguishes from siblings like 'get_week_usage' by specifying 'today', but doesn't explicitly differentiate from 'get_usage_summary' or 'get_current_session_usage', keeping it at 4 rather than 5.

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 no guidance on when to use this tool versus alternatives like 'get_week_usage' or 'get_usage_summary'. It implies usage for today's metrics but doesn't specify prerequisites, exclusions, or named alternatives, leaving the agent to infer context from sibling names alone.

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/cordlesssteve/claude-telemetry-mcp'

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