v1.0 · MCP server

@vk0/agent-cost-mcp

Local-first Claude Code cost analyzer. Parses JSONL session logs to surface per-tool spend, daily trends, and optimization hints. Zero cloud. No API key.

npm version MIT CI Node ≥18

When to install

Use this MCP server when the user asks any of:

Install

Pick your client. Everything runs through npx — nothing to install globally.

~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
{
  "mcpServers": {
    "agent-cost": {
      "command": "npx",
      "args": ["-y", "@vk0/agent-cost-mcp"]
    }
  }
}
One-liner via CLI
claude mcp add --transport stdio agent-cost -- npx -y @vk0/agent-cost-mcp
.cursor/mcp.json in your project root
{
  "mcpServers": {
    "agent-cost": {
      "command": "npx",
      "args": ["-y", "@vk0/agent-cost-mcp"]
    }
  }
}
Cline MCP settings (MCP Servers icon → Configure)
{
  "mcpServers": {
    "agent-cost": {
      "command": "npx",
      "args": ["-y", "@vk0/agent-cost-mcp"],
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

Tools

get_session_cost

Parse a single Claude Code session and return token totals, turn count, and estimated USD cost.

get_tool_usage

Aggregate tool invocations across a session or project log directory with per-tool context-share percentages.

get_cost_trend

Roll session logs into a day-by-day cost trend for a local project path.

suggest_optimizations

Generate lightweight optimization suggestions — cache ratios, abandoned calls, heaviest turns.

How it works

  ~/.claude/projects/*.jsonl           ┌─────────────────┐
  (Claude Code session logs)  ──────▶  │  JSONL parser   │
                                       │  + pricing.ts   │
                                       └────────┬────────┘
                                                │
                                                ▼
                                       ┌─────────────────┐
  Agent tool call (stdio MCP)  ──────▶ │  MCP server     │ ─── JSON response
                                       │  (4 tools)      │
                                       └─────────────────┘
        

Read-only on your local filesystem. No telemetry, no API key, no cloud sync. Delete the package and nothing remains.

Next

Full README & source on GitHub

npm package

Changelog

Report an issue