vk0dev avatar

Agent Cost Mcp

vk0dev/agent-cost-mcp

Reads your local Claude Code session JSONL files and surfaces tool-by-tool cost attribution, daily spend trends, and retry loop detection without sending anything to the cloud. Exposes eleven tools including get_tool_usage for per-tool burn analysis, get_subagent_tree for parent/child cost rollup, get_cost_forecast for forward-looking estimates, and configure_budget for hard caps with webhook alerts. Use it when Claude Code's built-in /cost command gives you a number but you need to know which specific tool, branch, or runaway pattern caused it. Runs entirely via npx with zero setup, parsing existing logs from ~/.claude/projects/ to answer forensic questions about where your tokens went and what should change next run.

tools
11
transport
STDIO
last updated
Jul 5, 2026

Tools

11 tools

Public tool metadata for what this MCP can expose to an agent.

get_session_costParse a single Claude Code session and return token totals, turn count, cache usage, and estimated USD cost so an agent can anchor every later Cost Guard question in one concrete run summary.

Parse a single Claude Code session and return token totals, turn count, cache usage, and estimated USD cost so an agent can anchor every later Cost Guard question in one concrete run summary.

No parameter schema in public metadata yet.

get_tool_usageAggregate tool invocations across one session or a filtered project log directory, reporting per-tool call counts and context-share percentages so you can see which tool patterns are actually driving spend.

Aggregate tool invocations across one session or a filtered project log directory, reporting per-tool call counts and context-share percentages so you can see which tool patterns are actually driving spend.

No parameter schema in public metadata yet.

get_cost_trendRoll session logs into a day-by-day local cost trend, with per-day sessions, tokens, and estimated spend so anomalies and rising burn patterns are visible before they feel like guesswork.

Roll session logs into a day-by-day local cost trend, with per-day sessions, tokens, and estimated spend so anomalies and rising burn patterns are visible before they feel like guesswork.

No parameter schema in public metadata yet.

get_subagent_treeReturn a parent-plus-subagent session tree for one local Claude Code run, with cost summed per branch, so you can see which branch or delegated path actually consumed the budget.

Return a parent-plus-subagent session tree for one local Claude Code run, with cost summed per branch, so you can see which branch or delegated path actually consumed the budget.

No parameter schema in public metadata yet.

get_tool_roiRank tools by a bounded ROI heuristic using cost share, linked results, and context share, so repeated calls with weak payoff surface quickly as the classic low-efficiency or runaway-loop signature.

Rank tools by a bounded ROI heuristic using cost share, linked results, and context share, so repeated calls with weak payoff surface quickly as the classic low-efficiency or runaway-loop signature.

No parameter schema in public metadata yet.

suggest_optimizationsGenerate lightweight optimization suggestions from a parsed session log, including cache-read ratios, abandoned tool calls, and heaviest turns, when you want the next fix to be more concrete than a raw metric table.

Generate lightweight optimization suggestions from a parsed session log, including cache-read ratios, abandoned tool calls, and heaviest turns, when you want the next fix to be more concrete than a raw metric table.

No parameter schema in public metadata yet.

detect_cost_anomaliesFlag unusually high or low daily cost spikes against the recent local baseline so sudden burn jumps, suspicious drops, and unstable usage patterns stand out without a separate monitoring stack.

Flag unusually high or low daily cost spikes against the recent local baseline so sudden burn jumps, suspicious drops, and unstable usage patterns stand out without a separate monitoring stack.

No parameter schema in public metadata yet.

get_cost_forecastProject a bounded local cost forecast from recent daily trend data so an operator can ask where spend is heading next, not just where it already went.

Project a bounded local cost forecast from recent daily trend data so an operator can ask where spend is heading next, not just where it already went.

No parameter schema in public metadata yet.

estimate_run_costEstimate the likely cost of a planned run before execution from prompt, model, and expected tool-call shape, returning {low, expected, high} with confidence for pre-spend decisions.

Estimate the likely cost of a planned run before execution from prompt, model, and expected tool-call shape, returning {low, expected, high} with confidence for pre-spend decisions.

No parameter schema in public metadata yet.

configure_budgetSet daily or per-session budget caps with tiered alert thresholds, so the next cost-query tool can return a machine-readable warning before an agent quietly runs past a soft or hard spending boundary.

Set daily or per-session budget caps with tiered alert thresholds, so the next cost-query tool can return a machine-readable warning before an agent quietly runs past a soft or hard spending boundary.

No parameter schema in public metadata yet.

set_monitor_webhookRegister an HMAC-signed webhook target for anomaly alerts, budget threshold crossings, and runaway flags so Cost Guard signals can leave the local session and reach an operator workflow when needed.

Register an HMAC-signed webhook target for anomaly alerts, budget threshold crossings, and runaway flags so Cost Guard signals can leave the local session and reach an operator workflow when needed.

No parameter schema in public metadata yet.

Sponsors

Readme

agent-cost-mcp

Local Cost Guard and runtime guardrails for AI agents in Claude Code.

Current v2.3.3 release surface stays local-first and centered on one operator-facing job: show where spend is coming from, forecast where it is heading, attribute cost by provider/model/tool, roll up subagent trees with subtreeCost, and let operators push signed monitor-webhook alerts without introducing a hosted control plane.

npm version license: MIT MCP Registry CI Node ≥18


View the full README on GitHub

Details

Repository
github.com/vk0dev/agent-cost-mcp
Category
AI & LLM Tools
Package
@vk0/agent-cost-mcp
Transport
STDIO
Registry
MCP registry, active

More from vk0dev

Related AI & LLM Tools MCP servers

View all
1wingedguardian avatarAgent Toolswingedguardian/agent-tools9 utility tools for agents: DNS, WHOIS, email, IP, URL, headers, QR, text, tech. x402 on Base.0stars
2twzrd-sol avatarTWZRD Agent Intelligencetwzrd-sol/twzrd-trustPre-spend trust for AI agents that buy: check x402 services and product listings before paying.0stars
3yourbright-jp avatarJPYC Agent MCPyourbright-jp/jpyc-agent-mcpOAuth-protected JPYC wallet, transfer, and contract workflows on Polygon.0stars
4neonia-io avatarNeonia: The Cloud Backend for AI Agentsneonia-io/agent-mcp-examplesMultiple MCP tools, persistent graph memory, token-saving data pointers, and more.0stars
5brajendrak00068 avatarLevea Mcp Serverbrajendrak00068/agentic-ai-video-productionAutonomous AI video editor over MCP: viral clips, captions, reframe, chroma key, MP4 export0stars
6corporatelad avatarPromptScancorporatelad/prompt-injection-firewallPrompt injection detection API for AI agents. Scan untrusted text before passing it to an LLM.0stars