agent-cost-mcp
Click on "Install 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-mcpshow 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: ohmytoken
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'
| Name | Required | Description | Default |
|---|---|---|---|
| period | No | today |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations exist, so description bears full burden. It only mentions the period argument but does not disclose behavioral traits like authentication needs, rate limits, or side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Very concise: two lines with a clear header and argument list. It is front-loaded and wastes no words, though a slightly more structured format could improve readability.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the presence of an output schema and a single simple parameter, the description is reasonably complete. However, it lacks usage context and behavioral details, which are gaps for a minimal viable description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema coverage, description compensates by listing valid values for 'period' ('today', 'week', 'month', 'all'), which is missing from the schema. This adds essential semantic information.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states 'Get a spending report' with a specific verb and resource. This distinguishes it from siblings like cost_trend, estimate_cost, etc., which serve different purposes.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool vs alternatives. The description does not mention context, prerequisites, or exclusions, leaving the agent without decision support.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
cost_trendB
Show daily spending trend as a text chart.
Args: days: Number of days to show (default: 7)
| Name | Required | Description | Default |
|---|---|---|---|
| days | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must disclose behavioral traits. It mentions the output is a 'text chart' but does not clarify if the tool is read-only, whether it aggregates historical data, or any side effects (e.g., idempotency). The description is too minimal to inform safe usage.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise with two sentences, no superfluous words, and front-loads the core purpose. It includes an Args block for parameter documentation, which is efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With an output schema present, the return values need not be described, but the description lacks details on the chart format (e.g., ASCII art, data density) and any limitations. It is adequate for a simple tool but leaves gaps for an AI agent to understand full behavior.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has 0% description coverage, but the description explains the 'days' parameter as 'Number of days to show (default: 7)', adding meaning beyond the schema's type and default. This compensates well for the single parameter, improving usability.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states the tool shows a daily spending trend as a text chart, which is a specific verb and resource. However, it does not distinguish from sibling tools like cost_report or estimate_cost, leaving ambiguity about when to use this particular tool.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus its siblings (cost_report, estimate_cost, etc.) or any exclusions. The description only states what the tool does, not the context of use.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
estimate_costA
Estimate cost without logging it. Use for planning.
Args: model: Model name tokens_in: Expected input tokens tokens_out: Expected output tokens
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | ||
| tokens_in | Yes | ||
| tokens_out | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must disclose behavior. It states the tool does not log (read-only), but does not mention that it returns a cost estimate based on current pricing, or any accuracy/limitations. The existence of an output schema partially compensates.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise: two sentences and a structured args list. It front-loads the key purpose and leaves no waste. Every sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple estimation tool with 3 parameters and an output schema, the description covers the basic intent. It lacks mention of approximation, currency, or error conditions, but these can be inferred or covered by the output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description must explain parameters. It lists model, tokens_in, and tokens_out with brief but sufficient descriptions. However, it could clarify that tokens_in and tokens_out refer to the model's token count expectations.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool estimates cost without logging, explicitly distinguishing it from logging tools. The verb 'estimate' and resource 'cost' are specific, and the purpose 'for planning' sets clear scope.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly says 'without logging it' and 'Use for planning', which implies when to use (planning) and when not (logging). It does not explicitly mention alternatives, but sibling tools like log_cost and cost_report provide context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | ||
| tokens_in | Yes | ||
| tokens_out | Yes | ||
| task | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It conveys that the tool logs data without side effects like modifying state or triggering other actions. Could add that it is a record-only operation, but current description is sufficient.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Description is extremely concise: two sentences for purpose and context, then a clean Args list. Every sentence adds value, no fluff, and front-loaded with the main action.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple logging tool with 4 parameters, the description covers the what, when, and how. Sibling tools provide context for when to use this vs others. An output schema exists but description doesn't need to detail return values.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, but the description compensates fully by defining each parameter (model with examples, tokens_in/tokens_out as input/output tokens, task as description). This adds meaning beyond the schema's type definitions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states it logs token usage and cost for a task, specifying to call after each AI interaction. It distinguishes from sibling tools like cost_report (for reports) and estimate_cost (for estimation) by focusing on per-interaction logging.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly says 'Call this after each AI interaction.' This provides clear when-to-use context. While not listing exclusions, the sibling tools offer natural alternatives for other needs, making usage clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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)
| Name | Required | Description | Default |
|---|---|---|---|
| daily_limit | No | ||
| monthly_limit | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It discloses that 0 means 'don't change' for both parameters, which is helpful. However, it does not mention behavioral traits like whether limits are cumulative, if previous limits are overridden, or any prerequisites.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise with two sentences plus parameter docs. It is front-loaded with the main purpose, and every line adds value without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that an output schema exists, the description does not need to explain return values. It adequately covers the tool's parameters and their special behavior (0 = no change). However, it lacks details on validation or side effects.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description explains each parameter's meaning beyond the schema: 'Maximum daily spend in USD (0 = don't change)' for daily_limit and similar for monthly_limit. This compensates for the 0% schema description coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Set daily and/or monthly budget limits' using a specific verb and resource. It distinguishes this tool from sibling tools like cost_report and estimate_cost, which report or estimate costs rather than set limits.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies when to use this tool (to set budget limits), and sibling tools are clearly different (reporting/estimation). However, it does not explicitly state when not to use it or provide alternative scenarios.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
supported_modelsA
List all supported models and their pricing.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, and description lacks behavioral details (e.g., read-only, rate limits). Only states output is a list, no mention of side effects or prerequisites.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence with no fluff. Front-loaded with verb and resource.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Simple list operation with output schema present. Description sufficient for basic use, though could detail listing order or filtering options.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
No parameters (empty schema) so baseline is 4. Description adds no param info, but none needed.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clear verb 'List' and specific resource 'supported models and their pricing.' Distinguishes from sibling tools like cost_report and estimate_cost.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool vs siblings. No explicit context for when to prefer this over cost_report or other listing tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
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
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Budget & cost control for AI agents — per-agent spend caps + rate limits before each call.
Track, analyze, and act on your streaming and SaaS subscriptions from any AI agent.
See, price, and control every tool call your AI agents make: policy checks, cost, and audit tools.
Agentic workflow budget approvals with usage receipts.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides real-time AI model pricing, cost estimation, and budget management tools to help agents understand and optimize their spending. It enables agents to compare costs across multiple providers and select the most cost-effective models for specific tasks.1
- FlicenseNot gradedqualityBmaintenanceReal-time context budget tracking for AI coding agents with token counting, loop detection, and alerts, backed by PostgreSQL.2
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to track LLM costs, enforce budgets, compare models, and estimate expenses through simple tool calls.
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/vanthienha199/agent-cost-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server