llmkit_local_projects
Track cumulative AI coding costs across all projects and sessions. Monitor spending from 11 AI providers to manage budgets and analyze usage patterns.
Instructions
Cumulative cost across all projects and sessions from all detected AI coding tools, ranked by spend.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The handler function that retrieves and formats project cost data from AI coding tool adapters.
export async function handleLocalProjects() { 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 found.'); allProjects.sort((a, b) => b.totalCost - a.totalCost); const totalCost = allProjects.reduce((s, p) => s + p.totalCost, 0); const lines = [ 'Project Costs (cumulative, all tools)', '\u2500'.repeat(25), `${allProjects.length} projects, $${totalCost.toFixed(2)} total`, '', ]; for (const p of allProjects) { const tokens = p.totalInputTokens + p.totalOutputTokens; lines.push(`${p.project}: $${p.totalCost.toFixed(2)} across ${p.sessionCount} sessions (${p.totalMessages} msgs, ${(tokens / 1000).toFixed(0)}k tokens) [${p.source}]`); } return ok(lines.join('\n'), { projects: allProjects, totalCostUsd: totalCost }); } - packages/mcp-server/src/tools.ts:152-164 (registration)The definition and schema registration of the llmkit_local_projects tool.
name: 'llmkit_local_projects', description: 'Cumulative cost across all projects and sessions from all detected AI coding tools, ranked by spend.', inputSchema: { type: 'object' as const, properties: {} }, outputSchema: { type: 'object' as const, properties: { projects: { type: 'array', items: { type: 'object', properties: { source: { type: 'string' }, project: { type: 'string' }, sessionCount: { type: 'number' }, totalCost: { type: 'number' }, totalMessages: { type: 'number' }, topModel: { type: 'string' } } } }, totalCostUsd: { type: 'number' }, }, required: ['projects', 'totalCostUsd'], }, annotations: { title: 'Project Costs', ...HINTS }, },