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
| Name | Required | Description | Default |
|---|---|---|---|
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 }, }, - packages/mcp-server/src/tools.ts:300-300 (registration)Registration of the 'llmkit_local_cache' tool in the HANDLER_MAP.
llmkit_local_cache: () => handleLocalCache(),