Real-time cost awareness for MCP agent workflows
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
We haven't yet run this listing's install command through our automated sandbox check. This isn't a red flag β we're steadily working through the catalog.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Inspect callable tools, capabilities, and parameters exposed to AI agents by MCP Cost Tracker Router.
get_session_costReturns token totals and USD cost estimates for the current session. Read-only.
get_tool_costsReturns per-tool cost breakdown for the session, sorted by cost descending. Read-only.
reset_sessionStart a new cost-tracking session. Previous session data is retained in history.
record_usageRecord token usage for a tool call. Takes `tool_name`, `model` (optional), `input_tokens`, and `output_tokens`. Emits a budget warning notification if 80% of threshold is reached.
set_budget_alertSet a budget threshold in USD (`threshold_usd`). Warns at 80% and 100% of the threshold. Use with `--enforce-budget` to block calls beyond the limit.
suggest_model_routingHeuristic model recommendation by task type. Takes `task_description` and optional `constraints.max_cost_usd`. Returns recommended model with reasoning and estimated cost.
npm mcp-cost-tracker-router package
Local-first cost awareness for MCP agent workflows. Token counts are calculated offline using js-tiktoken β no proxy, no API round-trip, no spend data leaving your machine. When costs climb, routing suggestions point you to cheaper models before the invoice arrives.
Tool reference | Configuration | Contributing | Troubleshooting
Most cost-tracking tools work by routing all your API traffic through their server and measuring tokens server-side. That means your prompts and responses transit a third-party service, and you're dependent on their uptime.
| mcp-cost-tracker-router | Proxy-based trackers (Helicone, LLMonitor, etc.) | |
|---|---|---|
| Token counting | Offline via js-tiktoken β no network call | Counted server-side after traffic is proxied |
| Data residency | Local SQLite only | Prompts + responses pass through vendor servers |
| Model routing | Built-in suggest_model_routing tool | Rarely included; usually a separate paid tier |
| Multi-provider | Claude, OpenAI, Gemini in one pricing table | Often single-provider or requires separate setup |
| Uptime dependency | None β fully offline | Breaks if proxy is down |
If your prompts contain sensitive information or you can't route traffic through a third party, this is the right tool. If you need a managed dashboard with team sharing, a proxy-based service may suit you better.
mcp-cost-tracker-router stores tool call metadata (token counts, model names, timestamps) locally in SQLite. It does not store prompt or response content. Cost calculations are estimates based on a local pricing table and may not exactly match your provider's invoice.
Add the following config to your MCP client:
To set a session budget alert:
Amp Β· Claude Code Β· Cline Β· Cursor Β· VS Code Β· Windsurf Β· Zed
Enter the following in your MCP client to verify everything is working:
Your client should return a token and USD cost summary for the current session.
get_session_cost β Returns token totals and USD cost estimates for the current session. Read-only.get_tool_costs β Returns per-tool cost breakdown for the session, sorted by cost descending. Read-only.reset_session β Start a new cost-tracking session. Previous session data is retained in history.record_usage β Record token usage for a tool call. Takes tool_name, model (optional), input_tokens, and output_tokens. Emits a budget warning notification if 80% of threshold is reached.set_budget_alert β Set a budget threshold in USD (threshold_usd). Warns at 80% and 100% of the threshold. Use with --enforce-budget to block calls beyond the limit.suggest_model_routing β Heuristic model recommendation by task type. Takes task_description and optional constraints.max_cost_usd. Returns recommended model with reasoning and estimated cost.check_routing_policy β Check whether a model is allowed for a given task type under the routing policy. Takes task_type and model.get_spend_history β Query historical spend aggregated by period (day/week/month). Returns breakdown by model and tool. Read-only.estimate_workflow_cost β Pre-run cost estimation for a multi-step workflow. Takes a steps array with tool_name, estimated_input_tokens, estimated_output_tokens, and optional model. Read-only.export_spend_report β Generate a single-file HTML spend report with session breakdown, historical spend, model cost comparison, and budget status. Read-only.export_budget_audit β Export the audit log of budget enforcement decisions. Accepts optional from_date, to_date, and format (json/csv). Read-only.set_project β Create or update a project with an optional budget_usd. Takes project_name.tag_session β Tag the current session with a project_name for cost allocation.get_project_costs β Get cost report for a project. Takes project_name and optional since (ISO date). Read-only.export_chargeback β Generate a chargeback report for internal billing. Takes from_date, to_date, optional group_by (project/session), and optional format (json/csv). Read-only.--budget-alertSession spend threshold in USD. A warning is returned when session costs reach 80% and again at 100% of this threshold.
Type: number
--db / --db-pathPath to the SQLite database file used to store cost history.
Type: string
Default: ~/.mcp/costs.db
--pricing-tablePath to a JSON file containing custom model pricing ($/1K tokens). Merged with the built-in table; missing models fall back to defaults.
Type: string
--default-modelModel name to attribute costs to when no model can be inferred from context.
Type: string
Default: claude-sonnet-4-6
--enforce-budgetBlock tool calls that would cause the session to exceed the budget alert threshold. Requires --budget-alert to be set.
Type: boolean
Default: false
--http-portStart in HTTP mode using Streamable HTTP transport instead of stdio. Useful for sharing a single cost-tracking instance across a team.
Type: number
Default: disabled (uses stdio)
Pass flags via the args property in your JSON config:
Built-in pricing table (USD per 1K tokens):
| Model | Input | Output |
|---|---|---|
| claude-opus-4-6 | $0.0150 | $0.0750 |
| claude-sonnet-4-6 | $0.0030 | $0.0150 |
| claude-haiku-4-5 | $0.0008 | $0.0040 |
| gpt-4o | $0.0025 | $0.0100 |
| gpt-4o-mini | $0.000150 | $0.000600 |
| gemini-1.5-pro | $0.001250 | $0.005000 |
| gemini-1.5-flash | $0.000075 | $0.000300 |
| gemini-2.0-flash | $0.000100 | $0.000400 |
Override individual model prices with --pricing-table. All costs are estimates.
Before publishing a new version, verify the server with MCP Inspector to confirm all tools are exposed correctly and the protocol handshake succeeds.
Interactive UI (opens browser):
CLI mode (scripted / CI-friendly):
Run before publishing to catch regressions in tool registration and runtime startup.
Update src/pricing.ts when new models are released. All cost calculation changes must include unit tests with known token counts and expected USD values. Routing suggestions live in src/tools/routing.ts.
This plugin is available on:
Search for mcp-cost-tracker-router.
Factual signals from GitHub, npm, and our automated checks β not a rating.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/mcp-cost-tracker-router)<a href="https://allmcps.com/mcp/mcp-cost-tracker-router"><img src="https://allmcps.com/api/badge/mcp-cost-tracker-router?style=directory" alt="MCP Cost Tracker Router on AllMCPs" /></a>