Skip to main content
Glama
cordlesssteve

Claude Telemetry MCP

get_usage_warnings

Monitor Claude usage and receive alerts when approaching typical limits to prevent unexpected costs or interruptions.

Instructions

Get usage warnings with default thresholds (80% and 90% of typical limits)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for 'get_usage_warnings'. Uses default token limits, calls checkUsageLimits on TelemetryService, and formats warnings for response.
    case 'get_usage_warnings': {
      // Use default thresholds
      const defaultLimits: UsageLimits = {
        dailyTokenLimit: 100000, // Example default
        weeklyTokenLimit: 500000, // Example default
        sessionTokenLimit: 50000, // Example default
      };
    
      const warnings = await this.telemetryService.checkUsageLimits(defaultLimits);
      return {
        content: [
          {
            type: 'text',
            text: this.formatUsageWarnings(warnings, true),
          },
        ],
      };
    }
  • src/index.ts:105-112 (registration)
    Tool registration in ListTools response, specifying name, description, and empty input schema.
    {
      name: 'get_usage_warnings',
      description: 'Get usage warnings with default thresholds (80% and 90% of typical limits)',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • Core helper function that computes usage warnings by comparing current metrics against provided limits at 80% and 90% thresholds.
    async checkUsageLimits(limits: UsageLimits): Promise<UsageWarnings> {
      const summary = await this.getUsageSummary();
      const warnings: string[] = [];
      const percentages: any = {};
    
      // Check daily limits
      if (limits.dailyTokenLimit) {
        const dailyPercent = (summary.today.tokens / limits.dailyTokenLimit) * 100;
        percentages.dailyTokens = dailyPercent;
        if (dailyPercent > 90) {
          warnings.push(`Daily token usage at ${dailyPercent.toFixed(1)}% of limit`);
        } else if (dailyPercent > 80) {
          warnings.push(`Daily token usage approaching limit (${dailyPercent.toFixed(1)}%)`);
        }
      }
    
      // Check weekly limits
      if (limits.weeklyTokenLimit) {
        const weeklyPercent = (summary.thisWeek.tokens / limits.weeklyTokenLimit) * 100;
        percentages.weeklyTokens = weeklyPercent;
        if (weeklyPercent > 90) {
          warnings.push(`Weekly token usage at ${weeklyPercent.toFixed(1)}% of limit`);
        } else if (weeklyPercent > 80) {
          warnings.push(`Weekly token usage approaching limit (${weeklyPercent.toFixed(1)}%)`);
        }
      }
    
      // Check session limits
      if (limits.sessionTokenLimit) {
        const sessionPercent = (summary.currentSession.tokens / limits.sessionTokenLimit) * 100;
        percentages.sessionTokens = sessionPercent;
        if (sessionPercent > 90) {
          warnings.push(`Session token usage at ${sessionPercent.toFixed(1)}% of limit`);
        } else if (sessionPercent > 80) {
          warnings.push(`Session token usage approaching limit (${sessionPercent.toFixed(1)}%)`);
        }
      }
    
      // Similar checks for cost limits...
      if (limits.dailyCostLimit) {
        const dailyCostPercent = (summary.today.cost / limits.dailyCostLimit) * 100;
        percentages.dailyCost = dailyCostPercent;
        if (dailyCostPercent > 80) {
          warnings.push(`Daily cost approaching limit (${dailyCostPercent.toFixed(1)}%)`);
        }
      }
    
      return {
        warnings,
        usage: {
          current: summary.today,
          limits,
          percentages
        }
      };
    }
  • Helper method to format UsageWarnings into a user-friendly markdown response.
    private formatUsageWarnings(warnings: UsageWarnings, isDefault: boolean = false): string {
      let result = '## Usage Warnings\n\n';
      
      if (warnings.warnings.length === 0) {
        result += '✅ No usage warnings - you\'re within safe limits\n\n';
      } else {
        result += '⚠️ **Warnings**:\n';
        warnings.warnings.forEach((warning: string) => {
          result += `- ${warning}\n`;
        });
        result += '\n';
      }
    
      if (isDefault) {
        result += '_Note: Using default limit thresholds. Use check_usage_limits with custom limits for precise tracking._\n\n';
      }
    
      result += '**Current Usage**:\n';
      result += `- Tokens: ${warnings.usage.current.tokens.toLocaleString()}\n`;
      result += `- Cost: $${warnings.usage.current.cost.toFixed(4)}\n`;
      result += `- Sessions: ${warnings.usage.current.sessions}\n`;
    
      return result;
    }
  • TypeScript interfaces defining UsageLimits (input-like for limits) and UsageWarnings (output structure) used by the tool.
    export interface UsageLimits {
      dailyTokenLimit?: number;
      weeklyTokenLimit?: number;
      sessionTokenLimit?: number;
      dailyCostLimit?: number;
      weeklyCostLimit?: number;
      sessionCostLimit?: number;
    }
    
    export interface UsageWarnings {
      warnings: string[];
      usage: {
        current: UsageData;
        limits: UsageLimits;
        percentages: {
          dailyTokens?: number;
          weeklyTokens?: number;
          sessionTokens?: number;
          dailyCost?: number;
          weeklyCost?: number;
          sessionCost?: 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 mentions 'default thresholds' but doesn't explain what constitutes a warning, how warnings are formatted, whether this is a read-only operation, or if it requires specific permissions. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 usage warnings') and adds necessary detail ('with default thresholds'). There is no wasted verbiage, 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 has 0 parameters, no output schema, and no annotations, the description is minimally adequate. It explains what the tool does but lacks details on behavior, output format, or integration with siblings. For a simple tool, this might suffice, but it doesn't fully address potential agent needs like understanding warning criteria.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description adds value by specifying that thresholds are defaulted to 80% and 90%, which provides context beyond the empty schema. This justifies a score above the baseline of 3.

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 with a specific verb ('Get') and resource ('usage warnings'), and specifies the scope ('with default thresholds'). It doesn't explicitly differentiate from siblings like 'check_usage_limits' or 'get_usage_summary', but the focus on warnings with thresholds provides some implicit distinction.

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?

No explicit guidance on when to use this tool versus alternatives is provided. The description mentions default thresholds (80% and 90%), which implies usage for monitoring near-limit scenarios, but it doesn't specify when to choose this over siblings like 'check_usage_limits' or 'get_usage_summary'.

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