Agent Cost Lens
Token cost analysis & prompt-cache recovery for Anthropic API agents.
Zero Prompt Exposure by Design. Agent Cost Lens is a metadata-only cost observability service and Model Context Protocol (MCP) server. Built with a strict local privacy boundary, it quantifies API spend and calculates cache-recovery metrics without ever touching your prompt text or source code. Launch Dashboard · GitHub Repository · $29/month
Key Architectural SpecificationsSystem Layer Implementation Specification Integration Pattern Local Python MCP Server (~4 vendored modules) + Hosted Fast-API / Cloud Run Server Data Ingestion Local Claude Code transcripts & apilog-v1 JSONL event log normalization Privacy Guarantee Zero-prompt wire schema; local HMAC-salted identifier pseudonymization Simulated Recovery Ground-truth-gated counterfactual simulator (CI band-locked to 0.77 measured ratio) Storage & Security Supabase Postgres (short-term raw event retention; aggregated day-level long-term metrics)Core Security & Privacy PrinciplesZero Prompt Ingestion: The client-server wire schema physically lacks fields for prompt text, completions, or code payloads.Local Anonymization: Repository and session identifiers are pseudonymized on your local machine using an HMAC salt that never leaves your environment.Client Auditability: Built-in preview_upload tool renders the exact outgoing wire payload before transmission, making security auditing a core feature.Fail-Loud Ingress: Bearer keys stored hash-only with instant flag-flip revocation, per-key rate limits, and strict ingress validation.System Architecture & Workflow1. Local Client (MCP Server)Runs entirely within your local execution environment. It ingests Claude Code transcripts or local JSONL API logs, normalizes them into stripped event schemas, applies local HMAC pseudonymization, and exposes local inspection tools before transmitting metadata.2. Hosted Engine (FastAPI / Cloud Run / Supabase)Operates on a scale-to-zero serverless footprint. It matches incoming event metadata against dated API rate cards, attributes cache hits vs. cache misses, and runs a nested-context counterfactual simulator to re-price turns and output ground-truth-gated "recovered $X" benchmarks.3. Isolated Billing Pipeline (Stripe)Built for minimal operational attack surface. Uses Stripe Payment Links and signature-verified webhooks (300s replay tolerance) with automated key revocation upon subscription cancellation. If billing services experience downtime, the system fails closed (503) without impacting core analyzer uptime.Engineering & Rigor~180 tests across 3 isolated suites. The core client engine relies strictly on the Python standard library. Every distributed artifact is a build-time snapshot of vendored code protected by byte-parity guards and developed via strict test-driven development (TDD).