AI cost tracking: 11 tools for spend, budgets, and Claude Code + Cursor + Cline costs
io.github.smigolsmigol/llmkit MCP Server
The Model Context Protocol (MCP) server io.github.smigolsmigol/llmkit provides AI cost tracking with 11 tools focused on measuring spend, tracking budgets, and estimating costs. It targets costs for Claude Code, Cursor, and Cline, and supports MCP as well as related runtime integrations.
🛠️ Key Features
11 tools for spend tracking and budget management
Cost estimation for Claude Code, Cursor, and Cline
Topics include cost-tracking, budget-enforcement, cost-estimation, and llm-observability
Implements MCP with references to durable-objects and API gateway patterns
Ecosystem mentions Cloudflare Workers and Vercel AI SDK
🚀 Use Cases
Measure what AI agents cost during execution
Stop or control requests when budget limits are exceeded
Track and estimate LLM spend across Claude Code, Cursor, and Cline workflows
⚡ Developer Benefits
Exposes MCP tooling for cost and budget workflows
Covers both Python and TypeScript-related tooling areas (per topics)
Includes observability-oriented topic coverage for LLM cost
⚠️ Limitations
Server description provided only emphasizes cost tracking and budgets; other MCP capabilities are not specified
LLMKit is an open-source AI gateway and SDK suite for cost attribution, budget admission, and
request evidence. The gateway reserves estimated spend before provider dispatch. It rejects
requests that cannot fit the active budget, then settles admitted reservations to actual usage when
the response completes.
The repository also ships local tracking surfaces that do not require an LLMKit account or proxy.
Choose a surface
Surface
Use it when
Package
Python transport
You want local cost estimates around existing SDK calls
from llmkit import tracked
from openai import OpenAI
costs = []
client = OpenAI(http_client=tracked(on_cost=costs.append))
client.chat.completions.create(
model="gpt-4.1",
messages=[{"role": "user", "content": "Summarize this incident."}],
)
print(f"${sum(item.total_cost or0for item in costs):.6f}")
The transport reads provider usage metadata and estimates cost from the bundled pricing catalog. It does not send tracking data to LLMKit.
Zero-code CLI tracking
bash
npx @f3d1/llmkit-cli -- python my_agent.py
Use -v for per-request output or --json for machine-readable results.
Gateway mode (existing key)
Gateway examples require an existing LLMKit API key. Account creation and key management are
temporarily unavailable while the authenticated service is restored. If you do not already have a
key, use one of the local tracking paths above.
The control path is built around three boundaries:
Atomic admission: a Durable Object owns reservation state for each budget scope. Concurrent
requests cannot spend the same remaining balance.
Dispatch-aware idempotency: deterministic failures before dispatch release the key. After
provider dispatch may have occurred, failures remain terminal to avoid duplicate spend.
Bounded responses: non-streaming bodies and individual SSE frames have explicit byte limits.
LLMKit cancels upstream reads when a limit is exceeded.
Request receipts bind the admission decision, provider attempt, settlement, and analytics handoff
with stable identifiers. Database writes use an outbox, so an analytics outage does not silently erase
budget evidence.
Five local tools inspect supported Claude Code sessions and Cline task data without an LLMKit key.
Six gateway tools query spend, budgets, keys, sessions, and service health when LLMKIT_API_KEY
contains an existing key. Together they expose 11 tools.
Pricing data
The pinned catalog is a bundled reference snapshot, not a live quote. One source file,
packages/shared/pricing.json, records the snapshot date and
generates the TypeScript, Python, and MCP tables. CI rejects drift between the source and generated
files. The public site renders only populated provider tables and displays the source date.
The public comparison endpoint requires no account:
The endpoint prices only the exact model keys supplied by the caller. It does not search for or
recommend the cheapest model. Pricing is an estimate, not a provider invoice. Provider billing rules,
model modality, and catalog freshness remain part of the error boundary.
Evidence and current boundary
Claim
Evidence in this repository
Boundary
Concurrent budget admission is serialized
Worker fixtures exercise competing reservations, retries, settlement, and recovery
Deterministic local Worker and database proof
Retry behavior avoids duplicate dispatch
Idempotency tests cover payload mismatch, pre-dispatch release, and post-dispatch indeterminate state
Provider behavior is simulated in CI
Large provider responses are bounded
Success, error, and unterminated SSE fixtures verify rejection and stream cancellation
Bound is per buffered response or SSE frame
Pricing artifacts are reproducible
One generator and CI --check path cover all published language tables
Catalog values still require source updates
Hosted recovery can be evaluated safely
Guarded staging deploy and proof runners bind an isolated Worker, database, revision, and cleanup journal
A completed hosted concurrency and outage-recovery receipt is not claimed here
See STAGING_PROOF.md for the isolated hosted proof contract. It deliberately refuses production targets and dirty worktrees.
Run the Worker locally with development-only bindings:
bash
corepack pnpm@9.15.4 --filter @f3d1/llmkit-proxy dev
Generic deploy commands are intentionally omitted. Staging and production use separate guarded scripts with explicit target confirmation.
Security
Provider credentials are encrypted with AES-256-GCM using a random IV and owner/provider-bound
additional authenticated data. LLMKit API keys are hashed before storage. CI includes secret
scanning, static analysis, dependency review, CodeQL, and package provenance checks.