Skip to main content
Glama

llmkit_local_forecast

Read-onlyIdempotent

Project monthly costs for local AI tool usage and compare them to Max subscription plans to optimize spending decisions.

Instructions

Monthly cost projection based on local AI tool usage. Compares to Max subscription.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalSessionsNo
dailyAverageUsdYes
totalTrackedUsdNo
projectedMonthlyUsdYes
maxSubscriptionSavingsUsdNo

Implementation Reference

  • Implementation of the tool handler for 'llmkit_local_forecast'. It calculates projected costs based on local AI tool data.
    export async function handleLocalForecast() {
      const active = await detectAdapters();
      if (active.length === 0) return fail('No AI coding tool data found. Works with Claude Code and Cline.');
    
      const allProjects: LocalProjectSummary[] = [];
      const results = await Promise.allSettled(active.map(a => a.getProjects()));
      for (const r of results) {
        if (r.status === 'fulfilled') allProjects.push(...r.value);
      }
    
      if (allProjects.length === 0) return fail('No project data for forecasting.');
    
      const totalCost = allProjects.reduce((s, p) => s + p.totalCost, 0);
      const totalSessions = allProjects.reduce((s, p) => s + p.sessionCount, 0);
    
      // project from actual date range, not hardcoded 30 days
      const timestamps = allProjects.map(p => p.latestTimestamp).filter(Boolean).sort();
      const earliest = timestamps[0] ?? '';
      const latest = timestamps[timestamps.length - 1] ?? '';
      const daySpan = earliest && latest
        ? Math.max(1, Math.ceil((new Date(latest).getTime() - new Date(earliest).getTime()) / 86400000) + 1)
        : 30;
      const dailyAvg = totalCost / daySpan;
      const monthlyProjection = dailyAvg * 30;
      const maxSavings = monthlyProjection - 200; // vs $200/mo Max subscription
    
      // legacy usage from old Claude Code versions
      const legacy = await getLegacyUsage();
    
      const lines = [
        'Cost Forecast (all tools)',
        '\u2500'.repeat(25),
        `Monthly projection: $${monthlyProjection.toFixed(2)} (API rates)`,
        `Daily average: $${dailyAvg.toFixed(2)}`,
        `Current period: $${totalCost.toFixed(2)} across ${totalSessions} sessions`,
        '',
        `Max ($200/mo) ${maxSavings > 0 ? `saves: $${maxSavings.toFixed(2)}/mo` : 'costs more than API rates'}`,
      ];
    
      if (legacy.totalCost > 0) {
        lines.push('', 'Historical usage (old Claude Code, no per-project breakdown):');
        for (const m of legacy.months) lines.push(`  ${m.month}: $${m.cost.toFixed(2)}`);
        lines.push(`  Total: $${legacy.totalCost.toFixed(2)}`);
      }
    
      const allTimeCost = totalCost + legacy.totalCost;
    
      return ok(lines.join('\n'), {
        projectedMonthlyUsd: monthlyProjection,
        dailyAverageUsd: dailyAvg,
        totalTrackedUsd: totalCost,
        totalSessions,
        legacyUsageUsd: legacy.totalCost,
        allTimeCostUsd: allTimeCost,
        maxSubscriptionSavingsUsd: maxSavings > 0 ? maxSavings : 0,
      });
    }
  • Tool definition/schema for 'llmkit_local_forecast'.
      name: 'llmkit_local_forecast',
      description: 'Monthly cost projection based on local AI tool usage. Compares to Max subscription.',
      inputSchema: { type: 'object' as const, properties: {} },
      outputSchema: {
        type: 'object' as const,
        properties: {
          projectedMonthlyUsd: { type: 'number' },
          dailyAverageUsd: { type: 'number' },
          totalTrackedUsd: { type: 'number' },
          totalSessions: { type: 'number' },
          maxSubscriptionSavingsUsd: { type: 'number' },
        },
        required: ['projectedMonthlyUsd', 'dailyAverageUsd'],
      },
      annotations: { title: 'Cost Forecast', ...HINTS },
    },
  • Registration of the 'llmkit_local_forecast' tool handler in the handler map.
    llmkit_local_forecast: () => handleLocalForecast(),
Behavior3/5

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

Annotations cover key behavioral traits: readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false. The description adds context by specifying it's for 'monthly cost projection' and 'compares to Max subscription', which provides additional meaning beyond annotations. However, it doesn't disclose details like rate limits, authentication needs, or specific output behavior, so it adds some value but not rich behavioral context.

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: 'Monthly cost projection based on local AI tool usage. Compares to Max subscription.' It is front-loaded with the core purpose and includes no wasted words, 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.

Completeness4/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, annotations provide safety and idempotency info, and an output schema exists, the description is mostly complete. It explains what the tool does and adds comparison context, but it could be more comprehensive by clarifying when to use it over siblings or detailing output specifics, though the output schema mitigates the latter gap.

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%, so there's no need for parameter details in the description. The baseline for such cases is 4, as the description appropriately focuses on the tool's purpose without redundant parameter information, and it adds semantic context about the forecast and comparison.

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: 'Monthly cost projection based on local AI tool usage. Compares to Max subscription.' It specifies the verb ('projection'), resource ('cost'), and scope ('local AI tool usage'), but doesn't explicitly differentiate from siblings like 'llmkit_cost_query' or 'llmkit_usage_stats', which might also relate to costs or usage.

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 is provided on when to use this tool versus alternatives. The description mentions comparing to 'Max subscription', but it doesn't clarify when this forecast is needed over other cost-related tools like 'llmkit_budget_status' or 'llmkit_cost_query', leaving usage context implied rather than stated.

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/smigolsmigol/llmkit-mcp-server'

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