Skip to main content
Glama

volt_get_spend

Retrieve spending summaries by provider and model for today, 7 days, or 30 days to analyze AI compute costs and optimize budget allocation.

Instructions

Get spending summary by provider and model for today, 7 days, or 30 days.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
time_rangeNoTime range for the summary: today, 7d (7 days), or 30d (30 days)today

Implementation Reference

  • The logic handler for the volt_get_spend tool.
    export function handleGetSpend(input: GetSpendInput, tracker: SpendTracker) {
      const summary = tracker.getSummary(input.time_range);
    
      if (summary.totalCalls === 0) {
        return {
          content: [
            {
              type: 'text' as const,
              text: `No inference calls recorded for ${input.time_range}. Spend data is collected as you use AI providers.`,
            },
          ],
        };
      }
    
      return {
        content: [
          {
            type: 'text' as const,
            text: formatSpendSummary(summary),
          },
        ],
      };
    }
  • Input validation schema for volt_get_spend.
    export const getSpendSchema = z.object({
      time_range: z
        .enum(['today', '7d', '30d'])
        .default('today')
        .describe('Time range for the summary: today, 7d (7 days), or 30d (30 days)'),
    });
  • Tool registration for volt_get_spend in the MCP server.
    server.tool(
      'volt_get_spend',
      'Get spending summary by provider and model for today, 7 days, or 30 days.',
      getSpendSchema.shape,
      async (input) => maybeAddFirstRun(handleGetSpend(getSpendSchema.parse(input), spendTracker)),
    );
  • Helper function to format the spending summary text for the tool output.
    function formatSpendSummary(s: SpendSummary): string {
      const lines: string[] = [
        `Spend Summary (${s.timeRange})`,
        '─'.repeat(60),
        `Total spend: $${s.totalSpend.toFixed(2)}`,
        `Total calls: ${s.totalCalls}`,
        `Avg cost/call: $${s.averageCostPerCall.toFixed(4)}`,
        `Tokens: ${s.totalTokensInput.toLocaleString()} input / ${s.totalTokensOutput.toLocaleString()} output`,
      ];
    
      const providerEntries = Object.entries(s.byProvider).sort((a, b) => b[1] - a[1]);
      if (providerEntries.length > 0) {
        lines.push('', 'By Provider:');
        for (const [provider, cost] of providerEntries) {
          const pct = s.totalSpend > 0 ? Math.round((cost / s.totalSpend) * 100) : 0;
          lines.push(`  ${provider}: $${cost.toFixed(2)} (${pct}%)`);
        }
      }
    
      const modelEntries = Object.entries(s.byModel).sort((a, b) => b[1] - a[1]);
      if (modelEntries.length > 0) {
        lines.push('', 'By Model:');
        for (const [model, cost] of modelEntries) {
          const pct = s.totalSpend > 0 ? Math.round((cost / s.totalSpend) * 100) : 0;
          lines.push(`  ${model}: $${cost.toFixed(2)} (${pct}%)`);
        }
      }
    
      return lines.join('\n');
    }
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 the tool retrieves a spending summary, implying a read-only operation, but doesn't address critical aspects like authentication requirements, rate limits, error handling, or the format of the returned summary. For a tool 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 clearly conveys the core functionality without any wasted words. It is front-loaded with the main action and scope, making it easy to parse quickly. Every part of the sentence earns its place by specifying key details like the summary breakdown and time ranges.

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 complexity (a read operation with one parameter) and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the spending summary includes (e.g., cost breakdowns, units), how results are structured, or any limitations (e.g., data latency, access controls). Without an output schema, the description should provide more context on return values, but it fails to do so.

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 description mentions the time range options ('today, 7 days, or 30 days'), which aligns with the input schema's parameter 'time_range' and its enum values. Since schema description coverage is 100%, the schema already fully documents the parameter, so the description adds minimal value beyond restating the enum options. This meets the baseline for high schema coverage.

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: 'Get spending summary by provider and model for today, 7 days, or 30 days.' It specifies the verb ('Get'), resource ('spending summary'), and scope ('by provider and model'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'volt_get_savings' or 'volt_check_price', which might also involve spending data.

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. It mentions the time ranges but doesn't explain why one would choose this tool over siblings such as 'volt_get_savings' or 'volt_recommend_route', nor does it specify any prerequisites or exclusions. This lack of contextual guidance leaves the agent to infer usage scenarios.

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/newageflyfish-max/volthq'

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