agent-cost-lens-mcp
This MCP server analyzes your Claude Code / Anthropic API token spend locally and returns cost summaries with recoverable-savings estimates — without sending prompt text or code.
analyze_costs — sweeps your local transcripts (or
apilogJSONL files via glob), scrubs identifiers on your machine, uploads usage metadata only to your configured Agent Cost Lens server, and returns your spend, cache-hit rate, and what caching fixes recover (simulated upper bounds, labeled as such).preview_upload — shows exactly what
analyze_costswould send: a sample of the scrubbed records plus every field name that travels. Sends nothing and needs no API key, so it works with zero configuration — the audit step.Names the caching fix — on API-log runs a pattern catalog flags your specific cache waste (uncached history, cache churn, volatile prefixes), prices recovery where the arithmetic supports it, and says so plainly where it doesn't.
Honest empty results — a workload with nothing to recover fires no patterns and reports none instead of inventing a fix.
Filtering — both tools take
since/untildates (YYYY-MM-DD) and anapilogglob;preview_uploadalso takes alimiton sampled records.Privacy — prompt text and code never leave your machine; repo and session names are HMAC-pseudonymized with a local salt at
~/.config/agent-cost-lens/salt.Offline export (CLI, not MCP) —
python3 -m acl_mcp.export --out records.jsonlwrites every scrubbedapilog-v1record to disk with no network access.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agent-cost-lens-mcp Preview my upload metadata before sending to server."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
name: agent-cost-lens-mcp description: See where your agent token money goes — and the caching fixes that recover it. Local sweep, local scrub, metadata-only upload — audit it yourself with preview_upload before anything is sent. capabilities: [cost-analysis, cache-waste-detection, caching-advice, spend-reporting]
Agent Cost Lens — MCP client
Two tools:
preview_upload — shows what would be sent (a sample of the scrubbed records, plus every field name that travels). Sends nothing. Works with zero configuration.
analyze_costs — sends that metadata to your Agent Cost Lens server and returns your spend, cache-hit rate, and what proper caching recovers (figures are simulated upper bounds, labeled as such).
Related MCP server: Azure FinOps MCP Server
It names the fix
On API-log runs the report goes past measurement: a pattern catalog names your
specific cache-waste — uncached history (missing cache_control on a stable
prefix), cache churn (write premium with little read-back), volatile prefixes
(something early in the prompt changing per request). Where the arithmetic
supports a figure, it prices what fixing that pattern recovers, computed from
your own usage and labeled (simulated); where it does not — two of the four
patterns carry no dollar figure, volatile prefixes and one-shot workloads — the
report says so in as many words rather than inventing one. When a workload has
nothing left to recover, no pattern fires and the report names none — it shows
you the measurement and stops, instead of manufacturing a fix. The one case it
calls out by name is the one-shot workload: "caching can't help one-shot
workloads." An empty catalog is a first-class result, not a failure state.
Export to a file (no server, no upload)
When you want every scrubbed record on disk — for a script of your own to read — ask for them explicitly:
python3 -m acl_mcp.export --out records.jsonl [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--project FOLDER]One apilog-v1 record per line, built by the same code and the same salt as an
upload, so exported and uploaded rows carry the same pseudonyms. --project
narrows the sweep to one folder under ~/.claude/projects/. The export path
imports nothing that can reach a network.
What it puts on your disk, all of it. Two files, not one:
the file you name — the only output, and replaced atomically. While the write is in flight a transient
<out>.<rand>.partsits beside it; that gets renamed over your file and is gone before the command returns.~/.config/agent-cost-lens/salt— 32 random bytes, created on the first run of a machine that has none, and only then; after that it is read, never rewritten. The salt is a file rather than a fresh random per run because that is what keeps a pseudonym stable: the same repo hashes to the same tag on your next run and on the upload path, which is the only reason an exported row and an uploaded row can be matched up. It stays on your machine.
Nothing else is written — no record store, no cache, no log.
Privacy
Prompt text and code never leave your machine — the wire format has no field
for them. Repo and session names are HMAC-pseudonymized with a salt that
never leaves ~/.config/agent-cost-lens/salt. Run preview_upload and read
the payload yourself; that output is the whole story.
Setup
{
"mcpServers": {
"agent-cost-lens": {
"command": "acl-mcp",
"env": {
"LENS_SERVER_URL": "https://your-analyzer.example",
"LENS_API_KEY": "acl_..."
}
}
}
}Install: pip install <tarball> (or uvx --from <dir> acl-mcp). Get a key
from the operator. preview_upload needs neither.
Available Tools
2 toolsanalyze_costsA
Analyze your Claude Code / Anthropic API token spend. Sweeps your local
transcripts (or apilog JSONL files via apilog glob), scrubs identifiers
on your machine, sends usage metadata only to your configured Agent Cost
Lens server, and returns the cost summary with recoverable savings.
Dates are YYYY-MM-DD. Use preview_upload first to audit what gets sent.
Inputs: since, until, apilog. Returns: result
preview_uploadA
Show exactly what analyze_costs WOULD upload — the scrubbed records, nothing else. Sends nothing; needs no key. This is the audit step.
Inputs: limit, since, until, apilog. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools are clearly distinct: preview_upload is a read-only audit step showing exactly what would be sent, while analyze_costs performs the actual sweep, upload, and summary. There is no meaningful overlap in their purposes.
Both tool names follow a consistent verb_noun snake_case pattern: analyze_costs and preview_upload. The naming convention is uniform and predictable.
Only two tools exist, which is slightly below the typical 3-15 range, but the domain is narrow and each tool earns its place: one main analysis/upload action and one preflight audit step. The count feels reasonable for the server's purpose.
The workflow is complete for the stated purpose: preview_upload covers the audit side and analyze_costs covers the actual analysis and upload. There are no obvious dead ends or missing operations within this narrow cost-analysis domain.
Maintenance
Related MCP Connectors
Agent FinOps Spend Guard, Deterministic Budget Passport, LLM Token Cost Router & VIP Discounts.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Track, analyze, and act on your streaming and SaaS subscriptions from any AI agent.
AI spend by team, developer and API key for Claude, OpenAI, Gemini and coding agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server that analyzes AI agent session logs to find token waste and optimization opportunities.7 npmMIT
- AlicenseNot gradedqualityDmaintenanceAnalyzes Azure cloud costs, audits for waste, and provides budget insights via natural language through a secure local MCP server.16 PyPI2MIT
- AlicenseAqualityDmaintenanceTracks AI agent token usage and spending in real time, with budget alerts, per-task cost breakdown, and a visual dashboard.61MIT
- AlicenseNot gradedqualityCmaintenanceLocal-first cost tracking and model routing for MCP agents with offline token counting, budget alerts, and spend reports.106 npmMIT