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-mcpPreview 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.
| Name | Required | Description | Default |
|---|---|---|---|
| since | No | ||
| until | No | ||
| apilog | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden and performs admirably. It discloses that the tool sweeps local transcripts, scrubs identifiers on the machine, sends only usage metadata to a configured server, and returns recoverable savings—key behavioral and privacy-relevant traits beyond what the schema shows.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and well-structured: one sentence states the core purpose, a second explains the operational flow, and the final sentence gives the date format and the prerequisite audit step. No sentences are wasted, and the most important context is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with three optional params, an output schema, and one sibling, the description provides comprehensive context: data sources, local processing, network transfer, return value, date format, and a safety instruction to preview first. Nothing critical is missing for an agent to invoke it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It does by clarifying that 'since' and 'until' are dates in YYYY-MM-DD format and that 'apilog' is a glob for JSONL files. It doesn't explain default semantics when these optional params are omitted, but it adds meaningful meaning beyond the raw schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description begins with a specific verb and resource: 'Analyze your Claude Code / Anthropic API token spend.' It then details the full workflow (sweeping transcripts, scrubbing identifiers, sending only usage metadata, returning a cost summary), making the tool's purpose concrete and distinguishable from the sibling preview_upload by framing preview_upload as a preliminary audit step.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear usage context, including the date format (YYYY-MM-DD) and an explicit sequencing instruction: 'Use preview_upload first to audit what gets sent.' It stops short of describing when not to use this tool or alternative conditions, but the guidance is sufficient for an agent to know when and how to proceed.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
preview_uploadA
Show exactly what analyze_costs WOULD upload — the scrubbed records, nothing else. Sends nothing; needs no key. This is the audit step.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| since | No | ||
| until | No | ||
| apilog | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden and does well by disclosing two key behaviors: it sends nothing and requires no key. It also scopes the result to 'the scrubbed records, nothing else.' It does not mention default limits or filtering behavior, but the output schema covers the return shape.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is three short sentences with no filler. It front-loads the core purpose, immediately states the safety-relevant behavior, and closes with the tool's role. Every sentence earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool has no annotations and no parameter descriptions in the schema, so the parameter semantics gap is significant. The description covers purpose and safety well but leaves the agent unable to correctly populate apilog or understand how since/until/limit shape the output. The presence of an output schema only partially compensates.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0% and the description does not explain any of the four parameters: limit, since, until, and apilog. While 'since' and 'until' are inferable as date bounds, 'apilog' remains opaque and there is no detail about how limit or the time filters affect the preview. The description only indirectly suggests these mirror analyze_costs.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Show') and a precise object ('what analyze_costs WOULD upload — the scrubbed records, nothing else'). It clearly differentiates this preview tool from the actual upload tool, analyze_costs, and reinforces the purpose by calling it 'the audit step.'
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description names analyze_costs as the related upload action, states that this tool sends nothing and needs no key, and labels itself as the audit step. This makes the intended pre-upload verification use case reasonably clear, though it does not explicitly say 'use this before analyze_costs' or list exclusion criteria.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v1.5.2- First observed
analyze_costs - First observed
preview_upload
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
Track, analyze, and act on your streaming and SaaS subscriptions from any AI agent.
See, price, and control every tool call your AI agents make: policy checks, cost, and audit tools.
OpenAI organization usage and cost reporting through an admin API key connected by the user.
AI agent infrastructure: dedup, cost prediction, validation, governance, failure intelligence.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server that analyzes AI agent session logs to find token waste and optimization opportunities.17 npmMIT
- AlicenseNot gradedqualityDmaintenanceAnalyzes Azure cloud costs, audits for waste, and provides budget insights via natural language through a secure local MCP server.2MIT
- AlicenseAqualityDmaintenanceTracks AI agent token usage and spending in real time, with budget alerts, per-task cost breakdown, and a visual dashboard.61MIT
- FlicenseNot gradedqualityCmaintenanceLocal LLM cost & token forensics proxy with anomaly detection, enabling security teams to scan for cost anomalies and abuse patterns, and expose results via MCP for autonomous agents.-