agent-cost-mcp
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-mcp show my spending for today"
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.
agent-cost-mcp
MCP server that tracks AI agent token usage and spending in real time. Budget alerts, per-task cost breakdown, visual dashboard, daily/weekly/monthly reports.
Works with any MCP client: Claude Code, Cursor, Windsurf, Codex, Gemini CLI, and more.


Why?
Every developer using AI agents worries about spending. Most tools don't tell you what each message costs until the bill arrives.
This MCP server tracks it in real time — per message, per model, per day. Set a budget, get alerts, see exactly where your money goes.
Related MCP server: contextpulse-mcp
Features
Visual dashboard — dark-themed web UI with spending charts, budget gauges, and activity log
Per-message cost logging — see what each AI interaction costs instantly
Budget alerts — warns when approaching daily/monthly limits
Cost reports — today, this week, this month, all time
Model breakdown — donut chart showing which model eats your budget
Spending trends — 14-day bar chart with color-coded spending
15+ models supported — Claude, GPT, DeepSeek, Gemini, Llama
Estimate before running — check cost before expensive tasks
Local storage — all data stays on your machine (
~/.agent-cost-mcp/)Auto-refresh — dashboard updates every 30 seconds
Quick Start
1. Install
pip install agent-cost-mcpOr with uv:
uv pip install agent-cost-mcp2. Add to your AI tool
Claude Code — add to ~/.claude/settings.json:
{
"mcpServers": {
"agent-cost": {
"command": "agent-cost-mcp"
}
}
}Cursor — add to .cursor/mcp.json:
{
"mcpServers": {
"agent-cost": {
"command": "agent-cost-mcp"
}
}
}Windsurf — add to MCP config:
{
"mcpServers": {
"agent-cost": {
"command": "agent-cost-mcp"
}
}
}3. Open the dashboard
open dashboard.htmlOr serve it locally:
cd ~/.agent-cost-mcp && python3 -m http.server 3456
# Open http://localhost:3456/dashboard.htmlThe dashboard reads from ~/.agent-cost-mcp/cost-log.json and auto-refreshes every 30 seconds. Leave it open in a browser tab while you work.
MCP Tools
These tools are available to any connected MCP client:
Tool | What it does | Example |
| Log token usage and cost for a task |
|
| Get spending report |
|
| Set daily/monthly budget limits |
|
| Show daily spending chart |
|
| Estimate cost without logging |
|
| List all models + pricing |
|
How It Works
You use Claude Code / Cursor / Windsurf normally
↓
MCP server logs each interaction (model, tokens, cost)
↓
Data saved to ~/.agent-cost-mcp/cost-log.json
↓
Dashboard reads the JSON and shows charts
↓
Budget alerts warn you before you overspendThe MCP server runs as a background process alongside your AI tool. You don't need to do anything extra — it tracks automatically when tools call log_cost.
Example Session
> How much did that last message cost?
Logged: $0.0165 (1,500 in / 800 out, claude-sonnet-4-6)
> Show my spending for today
# Cost Report — Today (2026-03-27)
- Messages: 26
- Tokens: 187,000 (118,000 in / 69,000 out)
- Total cost: $2.14
- Avg cost/message: $0.082
## By Model
claude-opus-4-6: $0.99 (46%)
claude-sonnet-4-6: $0.93 (43%)
gpt-5.4: $0.19 (9%)
deepseek-v3: $0.01 (1%)
gemini-2.5-flash: $0.00 (<1%)
## Budget
Daily: $2.14 / $5.00 (43%)
Monthly: $12.43 / $50.00 (25%)
> Set my daily budget to $3
Budget set: $3.00/day, $50.00/monthSupported Models
Model | Input ($/1M) | Output ($/1M) |
claude-opus-4-6 | $15.00 | $75.00 |
claude-sonnet-4-6 | $3.00 | $15.00 |
claude-haiku-4-5 | $0.80 | $4.00 |
gpt-5.4 | $2.50 | $10.00 |
gpt-5.2 | $1.50 | $6.00 |
gpt-5.1 | $0.60 | $2.40 |
gpt-4o | $2.50 | $10.00 |
gpt-4o-mini | $0.15 | $0.60 |
deepseek-v3 | $0.27 | $1.10 |
deepseek-r1 | $0.55 | $2.19 |
gemini-2.5-pro | $1.25 | $10.00 |
gemini-2.5-flash | $0.15 | $0.60 |
llama-4-maverick | $0.20 | $0.60 |
Missing a model? Open an issue or PR.
Data Storage
All data stored locally at ~/.agent-cost-mcp/cost-log.json. Nothing is sent to external services. Your spending data never leaves your machine.
Contributing
PRs welcome. Areas to improve:
Add more model pricing
Auto-detect token counts from MCP protocol metadata
Export reports to CSV/PDF
Slack/Discord alert integrations
License
MIT
Author
Built by Ha Le — University of Central Florida
Available Tools
6 toolscost_reportB
Get a spending report.
Args: period: 'today', 'week', 'month', or 'all'
Inputs: period. Returns: result
cost_trendB
Show daily spending trend as a text chart.
Args: days: Number of days to show (default: 7)
Inputs: days. Returns: result
estimate_costA
Estimate cost without logging it. Use for planning.
Args: model: Model name tokens_in: Expected input tokens tokens_out: Expected output tokens
Inputs: model (required), tokens_in (required), tokens_out (required). Returns: result
log_costA
Log token usage and cost for a task. Call this after each AI interaction.
Args: model: Model name (e.g., 'claude-sonnet-4-6', 'gpt-5.4') tokens_in: Number of input tokens tokens_out: Number of output tokens task: Description of what the task was
Inputs: model (required), tokens_in (required), tokens_out (required), task. Returns: result
set_budgetA
Set daily and/or monthly budget limits.
Args: daily_limit: Maximum daily spend in USD (0 = don't change) monthly_limit: Maximum monthly spend in USD (0 = don't change)
Inputs: daily_limit, monthly_limit. Returns: result
supported_modelsA
List all supported models and their pricing.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clear and distinct purpose: cost_report for spending summaries, cost_trend for daily trends, estimate_cost for planning, log_cost for recording usage, set_budget for limits, and supported_models for pricing info. No overlap.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., cost_report, set_budget). Even 'supported_models' fits as a verb+noun. The naming is predictable and clear.
With 6 tools, the server is well-scoped for cost management—covering logging, estimating, reporting, budgeting, and model listing. This is a natural and complete set without being excessive.
The surface covers main cost operations: logging, estimating, reporting, trending, and budget setting. Minor gaps like viewing current budget limits or resetting budgets exist, but these are not critical for the core workflow.
Maintenance
Related MCP Connectors
Enforce AI budgets before the model call and track cost per customer across 10 providers.
Budget & cost control for AI agents — per-agent spend caps + rate limits before each call.
Track API spend, credit balances and runway across OpenAI, Anthropic, OpenRouter and 25 more.
Cost per run, tool, model and day for AI agents, from one call or an OpenTelemetry export.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides real-time token pricing for AI models, model comparison, cost calculation, and token usage tracking for agents and developers.-
- FlicenseNot gradedqualityDmaintenanceReal-time context budget tracking for AI coding agents with token counting, loop detection, and alerts, backed by PostgreSQL.1-
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to track LLM costs, enforce budgets, compare models, and estimate expenses through simple tool calls.-
- AlicenseNot gradedqualityCmaintenanceLocal-first cost tracking and model routing for MCP agents with offline token counting, budget alerts, and spend reports.296 npmMIT