Measure
Break down recorded usage
Group requests by model, calculate input and output cost, account for cached input tokens, and summarize average request cost from supplied token counts.
Developer tools · MCP server
AI Cost Analyzer turns usage records you provide into model-level cost breakdowns, token-waste estimates, and daily or weekly trends. It also projects savings from caching, model routing, and context pruning; applies simple prompt-cleanup rules; and compares a bundled set of model prices.
$ npx -y ai-cost-analyzer
AI Cost Analyzer MCP server running on stdio
What it does
The package performs local calculations and returns text reports through MCP. It does not need access to an AI provider account to analyze the records passed into its tools.
Measure
Group requests by model, calculate input and output cost, account for cached input tokens, and summarize average request cost from supplied token counts.
Find
Estimate unused tool-definition tokens and oversized system-prompt tokens, then organize supplied timestamps into daily and weekly cost trends.
Explore
Project potential effects of prompt caching, cheaper-model routing, and context pruning, or inspect a cleaned-up copy of a prompt and its tool definitions.
Agent workflows
Each example is a complete argument object using the parameter names and value types accepted by the shipped server.
Audit a usage sample
analyze_usageGive the agent records from your own logs to calculate a cost summary, per-model breakdown, waste estimate, and time-based trends.
{
"usage_data": [
{
"model": "claude-sonnet",
"input_tokens": 12000,
"output_tokens": 1600,
"cached_tokens": 3000,
"timestamp": "2026-03-15T10:00:00Z",
"tool_definitions": 12,
"system_prompt_tokens": 2400
}
]
}
Project a monthly scenario
estimate_savingsAsk the agent to scale a usage sample and estimate savings from the analyzer's caching, routing, and pruning assumptions.
{
"usage_data": [
{
"model": "gpt-4o",
"input_tokens": 8000,
"output_tokens": 900,
"cached_tokens": 0,
"timestamp": "2026-03-15T09:00:00Z",
"tool_definitions": 10
}
],
"monthly_multiplier": 30
}
Review repeated prompt context
optimize_promptHave the agent return a cleaned-up prompt copy, estimated token counts, a cost projection, and recommendations. The original prompt is not modified.
{
"system_prompt": "You are a support assistant. Please make sure to always answer concisely.",
"tool_definitions": [
"{\"name\":\"search_docs\",\"description\":\"Search product documentation\"}"
],
"requests_per_month": 10000,
"model": "claude-sonnet"
}
Quickstart
No global install is required. The package supports Node.js 18 or newer and starts with the stdio transport by default.
~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json. In the app: Settings → Developer → Edit Config.
~/.cursor/mcp.json
Or .cursor/mcp.json inside a single project.
~/.codeium/windsurf/mcp_config.json
Cascade panel → MCP icon → edit the raw config.
All three clients accept the same object. If the file already has an mcpServers block, add just the "ai-cost-analyzer" entry inside it.
{
"mcpServers": {
"ai-cost-analyzer": {
"command": "npx",
"args": ["-y", "ai-cost-analyzer"]
}
}
}
No env block is needed to start: the first 3 tool calls total across this server's tools run without a license.
$ claude mcp add --transport stdio ai-cost-analyzer -- npx -y ai-cost-analyzer
Check it registered with claude mcp list. Add a key later with --env LICENSE_KEY=your-key placed before --transport.
claude mcp list and look for ✔ Connected.Running npx -y ai-cost-analyzer in a terminal looks frozen — that is correct. It is a stdio server: it waits silently for an MCP client on stdin and never returns a prompt. Press Ctrl+C to exit. Use the config above rather than the bare command; your client starts the process for you.
A key arrives on screen right after checkout. Add it as an environment variable in the same entry:
{
"mcpServers": {
"ai-cost-analyzer": {
"command": "npx",
"args": ["-y", "ai-cost-analyzer"],
"env": {
"LICENSE_KEY": "paste-your-key-here"
}
}
}
}
Keys are verified offline against a public key compiled into the package — no account, no network check, no usage reporting. Lost the key? Recover it here. More detail on the FAQ.
Scope & limitations
The server is an estimator and text-analysis utility, not a provider billing system or an optimization runtime.
It does not connect to Anthropic, OpenAI, or Google accounts, collect live traffic, read invoices, or import provider exports. You supply each usage record to analyze.
Rates are bundled in the package and labeled March 2026. They cover Claude Opus, Sonnet, and Haiku; GPT-4o and GPT-4o Mini; and Gemini 2.0 Flash. The server does not fetch live provider pricing.
Waste and savings projections use assumptions in the package. Prompt token counts use an approximate four characters per token, and model recommendations use rule-based task classification—not measured benchmarks.
The server does not enable caching, route production requests, change model settings, edit source files, or deploy prompts. Review returned prompt text and projections before applying them yourself.
Start with your own records
Add the package to an MCP client without a license key, then pass a small, representative usage sample to the analyzer.