Skip to main content
Glama

llmkit_local_cache

Analyze prompt caching savings across AI coding tools to track cost reductions from cached responses.

Instructions

Cache savings analysis across all detected AI coding tools. Shows how much prompt caching saved.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The 'handleLocalCache' function calculates and reports prompt caching savings by aggregating data from available AI tool adapters.
    export async function handleLocalCache() {
      const active = await detectAdapters();
      if (active.length === 0) return fail('No AI coding tool data found. Works with Claude Code and Cline.');
    
      const results = await Promise.allSettled(active.map(a => a.getCacheSavings()));
      const savings = results
        .map(r => r.status === 'fulfilled' ? r.value : null)
        .filter(s => s !== null);
    
      if (savings.length === 0) return fail('No cache data found.');
    
      const totalSaved = savings.reduce((s, x) => s + x.totalSaved, 0);
      const lines = [
        'Cache Savings (all tools)',
        '\u2500'.repeat(25),
        `Total saved: $${totalSaved.toFixed(4)}`,
        '',
      ];
    
      for (const s of savings) {
        lines.push(`${s.source}: saved $${s.totalSaved.toFixed(4)}, ${s.readToWriteRatio.toFixed(1)}x read/write ratio`);
        for (const m of s.models) {
          lines.push(`  ${m.model}: saved $${m.saved.toFixed(4)}, ${m.ratio.toFixed(1)}x ratio (${(m.cacheRead / 1000).toFixed(0)}k reads, ${(m.cacheWrite / 1000).toFixed(0)}k writes)`);
        }
      }
    
      return ok(lines.join('\n'), { savings, totalSavedUsd: totalSaved });
    }
  • Definition of the 'llmkit_local_cache' tool including input/output schemas and description.
      name: 'llmkit_local_cache',
      description: 'Cache savings analysis across all detected AI coding tools. Shows how much prompt caching saved.',
      inputSchema: { type: 'object' as const, properties: {} },
      outputSchema: {
        type: 'object' as const,
        properties: {
          savings: { type: 'array', items: { type: 'object', properties: { source: { type: 'string' }, totalSaved: { type: 'number' }, readToWriteRatio: { type: 'number' } } } },
          totalSavedUsd: { type: 'number' },
        },
        required: ['totalSavedUsd'],
      },
      annotations: { title: 'Cache Savings', ...HINTS },
    },
  • Registration of the 'llmkit_local_cache' tool in the HANDLER_MAP.
    llmkit_local_cache: () => handleLocalCache(),

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