Skip to main content
Glama
wn01011

llm-token-tracker

get_usage

Retrieve token usage summaries for OpenAI and Claude APIs to monitor consumption and manage costs.

Instructions

Get usage summary

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNoUser ID (optional)

Implementation Reference

  • The primary handler function for the 'get_usage' tool. Processes arguments to retrieve and format usage summary for a specific user_id or all users, returning structured content with token counts and costs.
    private getUsage(args: any) {
      const { user_id } = args;
      
      if (user_id) {
        const usage = this.tracker.getUserUsage(user_id);
        if (!usage) {
          return {
            content: [{ type: 'text', text: `No usage data for ${user_id}` }]
          };
        }
        
        let summary = `📊 Usage Summary for ${user_id}\n`;
        summary += `Total: ${usage.totalTokens} tokens (${formatCost(usage.totalCost)})\n\n`;
        Object.entries(usage.usageByModel).forEach(([model, data]) => {
          summary += `${model}: ${data.tokens} tokens (${formatCost(data.cost)})\n`;
        });
        
        return {
          content: [{ type: 'text', text: summary }]
        };
      } else {
        const allUsage = this.tracker.getAllUsersUsage();
        let summary = '📊 All Users:\n';
        allUsage.forEach(user => {
          summary += `${user.userId}: ${user.totalTokens} tokens (${formatCost(user.totalCost)})\n`;
        });
        
        return {
          content: [{ type: 'text', text: summary || 'No usage data' }]
        };
      }
    }
  • Tool registration in ListToolsRequestSchema handler, defining name, description, and input schema for 'get_usage'.
    {
      name: 'get_usage',
      description: 'Get usage summary',
      inputSchema: {
        type: 'object',
        properties: {
          user_id: {
            type: 'string',
            description: 'User ID (optional)'
          }
        }
      }
    },
  • Dispatch routing in CallToolRequestSchema handler that maps 'get_usage' tool calls to the getUsage method.
    case 'get_usage':
      return this.getUsage(request.params.arguments);
  • Input schema definition for the get_usage tool, specifying optional user_id parameter.
    inputSchema: {
      type: 'object',
      properties: {
        user_id: {
          type: 'string',
          description: 'User ID (optional)'
        }
      }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Get usage summary' implies a read operation, but it doesn't specify if it's safe, requires authentication, has rate limits, or what the output format might be. It's minimal and lacks critical behavioral details.

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 extremely concise with just three words, front-loaded and zero waste. It efficiently states the core action without unnecessary elaboration, though this brevity contributes to gaps in other dimensions.

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

Completeness2/5

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

Given the complexity of a usage-related tool with no annotations and no output schema, the description is incomplete. It doesn't explain what 'usage' refers to, what data is returned, or how to interpret results, leaving significant gaps for an AI agent to understand and use the tool effectively.

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?

The input schema has 100% coverage, fully describing the optional 'user_id' parameter. The description adds no additional meaning beyond what the schema provides, such as explaining what 'usage summary' includes or how the parameter affects results. Baseline 3 is appropriate 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.

Purpose2/5

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

The description 'Get usage summary' restates the tool name 'get_usage' in a slightly different phrasing, making it tautological. It doesn't specify what type of usage (e.g., API, resource, billing) or what 'summary' entails, leaving the purpose vague beyond the obvious from the name.

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 guidance is provided on when to use this tool versus alternatives like 'track_usage' or 'compare_costs' among the sibling tools. The description lacks context about prerequisites, timing, or specific use cases, offering no help in tool selection.

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/wn01011/llm-token-tracker'

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