Skip to main content
Glama
wn01011

llm-token-tracker

compare_costs

Compare token costs across AI models to analyze pricing differences and optimize API usage for budget management.

Instructions

Compare costs between models

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokensYesNumber of tokens to compare

Implementation Reference

  • The handler function that executes the compare_costs tool. It simulates token usage for various models using the TokenTracker and compares their costs, returning a formatted comparison string.
    private compareCosts(args: any) {
      const { tokens } = args;
      
      const models = [
        { provider: 'openai' as const, model: 'gpt-3.5-turbo', name: 'GPT-3.5' },
        { provider: 'openai' as const, model: 'gpt-4', name: 'GPT-4' },
        { provider: 'anthropic' as const, model: 'claude-3-haiku-20240307', name: 'Claude Haiku' },
        { provider: 'anthropic' as const, model: 'claude-3-sonnet-20240229', name: 'Claude Sonnet' },
        { provider: 'anthropic' as const, model: 'claude-3-opus-20240229', name: 'Claude Opus' },
        { provider: 'gemini' as const, model: 'gemini-1.5-flash', name: 'Gemini Flash' },
        { provider: 'gemini' as const, model: 'gemini-1.5-pro', name: 'Gemini Pro' }
      ];
      
      const comparison = models.map(({ provider, model, name }) => {
        const trackingId = this.tracker.startTracking('_compare');
        this.tracker.endTracking(trackingId, {
          provider,
          model,
          inputTokens: Math.floor(tokens / 2),
          outputTokens: Math.ceil(tokens / 2),
          totalTokens: tokens
        });
        const usage = this.tracker.getUserUsage('_compare');
        const cost = usage?.usageByModel[`${provider}/${model}`]?.cost || 0;
        this.tracker.clearUserUsage('_compare');
        
        return { name, cost };
      }).sort((a, b) => a.cost - b.cost);
      
      let result = `💰 Cost comparison for ${tokens} tokens:\n\n`;
      comparison.forEach((item, i) => {
        const emoji = i === 0 ? '🏆' : i === 1 ? '🥈' : i === 2 ? '🥉' : '  ';
        result += `${emoji} ${item.name}: ${formatCost(item.cost)}\n`;
      });
      
      return {
        content: [{ type: 'text', text: result }]
      };
    }
  • The tool registration in the ListToolsRequestSchema handler, including name, description, and input schema definition.
    {
      name: 'compare_costs',
      description: 'Compare costs between models',
      inputSchema: {
        type: 'object',
        properties: {
          tokens: {
            type: 'number',
            description: 'Number of tokens to compare'
          }
        },
        required: ['tokens']
      }
    },
  • The input schema definition for the compare_costs tool.
    inputSchema: {
      type: 'object',
      properties: {
        tokens: {
          type: 'number',
          description: 'Number of tokens to compare'
        }
      },
      required: ['tokens']
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. The description only states what the tool does at a high level ('compare costs') without explaining how it behaves: whether it requires authentication, what data sources it uses, whether it makes network calls, what format the comparison results take, or any rate limits. This leaves significant gaps in understanding the tool's operational characteristics.

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 at just three words: 'Compare costs between models'. It's front-loaded with the core action and contains no unnecessary information. Every word serves a purpose in conveying the tool's function.

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 tool's apparent complexity (comparing costs between models likely involves multiple data sources and calculations), the description is insufficient. With no annotations, no output schema, and only a minimal description, there's inadequate information about what the tool returns, how it performs comparisons, or what models are involved. The description doesn't compensate for the lack of structured metadata.

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% description coverage, with the single parameter 'tokens' clearly documented as 'Number of tokens to compare'. The description doesn't add any additional meaning beyond what the schema provides—it doesn't explain what 'tokens' represent in context or how they relate to cost comparison. With high schema coverage, the baseline score of 3 is appropriate.

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

Purpose3/5

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

The description 'Compare costs between models' states a general purpose but lacks specificity. It mentions the verb 'compare' and resource 'costs between models', but doesn't specify what models are being compared or how the comparison works. It doesn't distinguish from sibling tools like 'get_exchange_rate' or 'track_usage' which might involve cost-related operations.

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. There are no explicit instructions about when to invoke it, when not to use it, or what alternatives exist among the sibling tools. The user must infer usage from the tool name 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/wn01011/llm-token-tracker'

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