AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
MCP verified MIT Self-run

Agentmeter

mcp-ymstar-agentmeter Β· by ymstar

🎯 Track AI agent token usage, costs & cache hit rates. CLI + dashboard for Claude Code, Cursor & Gemini CLI. Budget alerts, multi-model pricing, zero config.

β€” No reviews yet
0 installs
10 views
0.0% view→install

Install

$ agentstack add mcp-ymstar-agentmeter

βœ“ scanned Β· βœ“ verified, works with Claude Code, Cursor, and more.

Security review

βœ“ Passed

No issues found. Passed automated security review. Β· v0.1.0 How review works β†’

  • βœ“ Prompt-injection patterns
  • βœ“ Secret / credential exfiltration
  • βœ“ Dangerous shell & filesystem operations
  • βœ“ Untrusted network calls
  • βœ“ Known-malicious package signatures

What it can access

  • βœ“ Network access No
  • βœ“ Filesystem access No
  • βœ“ Shell / process execution No
  • βœ“ Environment & secrets No
  • βœ“ Dynamic code execution No

From automated source analysis of v0.1.0. β€œUsed” means the capability is present in the source β€” more access means more to trust, not that it’s unsafe.

View the full security report β†’

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/mcp-ymstar-agentmeter)

Reliability & compatibility

βœ“ Security review passed
0 installs to date
β€” no reviews yet
● 2mo ago

Declared compatibility

Claude CodeClaude DesktopCursorWindsurf

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work β†’
Are you the author of Agentmeter? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Open-source token usage & cost tracking CLI for AI coding agents. Automatically monitor Claude Code token consumption, cache hit rates, and API costs. Beautiful dashboard β€’ Budget alerts β€’ Multi-model pricing β€’ Local-first SQLite storage.


Why AgentMeter?

| Feature | AgentMeter | Manual Tracking | API Dashboard | |---------|-----------|----------------|---------------| | Automatic tool-call tracking | βœ… | ❌ | ❌ | | Cache hit rate monitoring | βœ… | ❌ | ❌ | | Per-session & per-tool breakdown | βœ… | ❌ | ⚠️ | | Multi-model pricing (Claude, GPT, Gemini, DeepSeek) | βœ… | ❌ | ❌ | | Budget alerts & spending limits | βœ… | ❌ | ⚠️ | | Local-first (no cloud dependency) | βœ… | βœ… | ❌ | | Beautiful web dashboard | βœ… | ❌ | βœ… | | Zero config setup | βœ… | ❌ | ❌ | | CSV/JSON export | βœ… | ❌ | ⚠️ |

AgentMeter hooks into Claude Code's PostToolUse event β€” every tool call is automatically captured with token usage, model info, cache stats, and estimated cost. No manual logging, no API polling, no cloud services.

Quick Start

# One command to set up
npx @ymstar/agentmeter init

# Launch dashboard
npx @ymstar/agentmeter dashboard

That's it. AgentMeter will automatically track all tool calls in the background.

Features

  • Zero Config β€” One init command sets up Claude Code hooks
  • Auto Tracking β€” Captures every tool call automatically
  • Beautiful Dashboard β€” Dark-themed web UI with charts and sparklines
  • Multi-View β€” Analyze by tool, session, model, or agent type
  • Cache Hit Tracking β€” Shows cache hit/miss rate per call and in aggregate
  • Multi-Model Pricing β€” Built-in pricing for Claude, GPT, Gemini, DeepSeek, MiMo, GLM
  • Effort Tracking β€” Records effort level (high/medium/low) per call
  • Budget Alerts β€” Set spending limits and get warnings
  • Token Estimation β€” Smart 3-layer token counting (parse β†’ estimate β†’ fallback)
  • CJK Aware β€” Accurate token estimation for Chinese/Japanese/Korean text
  • Data Export β€” Export to CSV or JSON
  • Local Storage β€” All data stored locally in SQLite

Commands

| Command | Description | |---------|-------------| | agentmeter init | Configure Claude Code hooks (one-time) | | agentmeter dashboard | Launch web dashboard | | agentmeter stats | Show stats in terminal | | agentmeter budget | Check budget status and warnings | | agentmeter export | Export data to CSV or JSON | | agentmeter reset | Clear all recorded data and start fresh |

agentmeter dashboard

agentmeter dashboard            # default port 3940
agentmeter dashboard --port 8080

The dashboard shows:

  • Today / Week / Month token usage cards with sparklines
  • Cache Hit Rate card with hit/miss breakdown
  • Token consumption trend chart (7 / 30 / 90 days) with cache read overlay
  • Cost by model doughnut chart
  • Top tools by token usage doughnut chart
  • Hourly activity bar chart
  • By Tool β€” Statistics grouped by tool name
  • By Session β€” Statistics grouped by Claude Code session
  • By Model β€” Statistics grouped by LLM model
  • By Agent β€” Statistics grouped by agent type
  • Recent Calls β€” Each call shows model, effort level, cache hit rate, and cost

agentmeter export

agentmeter export                        # CSV to stdout, last 30 days
agentmeter export -f json -o data.json   # JSON to file
agentmeter export -d 7                   # Last 7 days

agentmeter budget

agentmeter budget

Shows daily and monthly spending against configured limits.

agentmeter reset

agentmeter reset          # prompts for confirmation
agentmeter reset --force  # skip confirmation

Configuration

AgentMeter stores config at ~/.agentmeter/config.json:

{
  "daily_limit_usd": 10,
  "monthly_limit_usd": 100,
  "daily_limit_tokens": 5000000,
  "monthly_limit_tokens": 50000000,
  "warn_at_percent": 80
}

How It Works

  1. agentmeter init adds a PostToolUse hook to ~/.claude/settings.json
  2. Every time Claude Code uses a tool, the hook fires and captures the call
  3. AgentMeter parses token usage, detects model & agent type, estimates cost
  4. Data is stored in ~/.agentmeter/meter.db (SQLite)
  5. View stats via agentmeter dashboard or agentmeter stats

Model Detection

AgentMeter auto-detects the model from Claude Code's environment:

  1. Hook input field β†’ 2. Environment variables (ANTHROPIC_MODEL, CLAUDE_MODEL, OPENAI_MODEL) β†’ 3. ~/.claude/settings.json β†’ 4. Default to Claude Sonnet

Agent type detection (identifies Claude Code):

  1. CLAUDECODE env var β†’ 2. CLAUDE_CODE_SESSION_ID env var β†’ 3. Session ID format β†’ 4. ~/.claude directory β†’ 5. Model name pattern

Cache Token Tracking

When Claude Code uses prompt caching, the API returns cache_creation_input_tokens and cache_read_input_tokens. AgentMeter captures these and calculates:

  • Cache Hit Rate β€” percentage of input tokens served from cache
  • Cache-aware cost β€” cache reads are cheaper (e.g., Claude: 0.1x input price)

Model Pricing

Built-in per-1M-token pricing (input / output / cache read / cache write):

| Model Family | Models | Input | Output | |-------------|--------|-------|--------| | Claude | Opus 4, Sonnet 4, 3.5 Sonnet, 3.5 Haiku, 3 Opus | $0.8–$15 | $4–$75 | | GPT | 4o, 4o-mini, 4-turbo, 3.5-turbo | $0.15–$10 | $0.6–$30 | | Gemini | 2.5 Pro, 2.5 Flash, 2.0 Flash | $0.1–$1.25 | $0.4–$10 | | DeepSeek | v4-flash, v4-pro, v3.2, r1 | $0.14–$1.74 | $0.28–$3.48 | | MiMo | v2.5-pro, v2.5, v2-flash | $0.1–$1 | $0.3–$3 | | GLM | 5.1, 5, 4.7, 4.7-flash, 4.5-air | $0.06–$1.2 | $0.4–$4 |

Unknown models default to Claude Sonnet pricing.

Supported Agents

  • Claude Code β€” fully supported via PostToolUse hook
  • Cursor / Gemini CLI / others β€” not yet supported, contributions welcome

Development

git clone https://github.com/ymstar/agentmeter.git
cd agentmeter
npm install
npm run build
npm test

No linter configured β€” CI type-checks with npx tsc --noEmit on Node 20 and 22.

License

[MIT](LICENSE)


Use Cases Claude Code cost tracking β€’ AI agent token monitoring β€’ LLM API budget management β€’ Developer productivity analytics β€’ Multi-model usage comparison β€’ Prompt caching optimization

Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source β€” we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.