MCP Cost Tracker Router
Track token spend per tool, set budget alerts and get cheaper-model suggestions
- Platforms
- CLI, self-hosted
- Runs
- Locally
- Version
- 1.0.1
- Listing updated
- 3 days ago
Similar MCP servers
About MCP Cost Tracker Router
MCP Cost Tracker Router is an MCP server for developer tools. It runs locally on your machine and is started by your AI client.
The server keeps a local ledger of what an agent session costs. The agent reports usage per tool call, and the tracker converts token counts into dollars using a built-in table for Claude, OpenAI and Gemini models that you can extend with your own prices. Counting is offline through js-tiktoken, and only metadata (token counts, model names, timestamps) is stored in SQLite, never prompt or response text.
Beyond tallies it can warn at 80% and 100% of a session budget and, with a flag, block calls that would exceed it. Routing suggestions recommend a cheaper model for a task description, but only as advice. History queries roll spend up by day, week or month, projects can be tagged for chargeback reports, and a single-file HTML report plus an audit log of budget decisions can be exported.
The README notes the figures are estimates from a local table and may not match a provider invoice. It needs Node 20.19 or newer.
Install
Run in a terminal
claude mcp add mcp-cost-tracker-router --env YOUR_API_KEY='<YOUR_API_KEY>' -- npx -y mcp-cost-tracker-routerAdd to claude_desktop_config.json
{
"mcpServers": {
"mcp-cost-tracker-router": {
"command": "npx",
"args": [
"-y",
"mcp-cost-tracker-router"
],
"env": {
"YOUR_API_KEY": "<YOUR_API_KEY>"
}
}
}
}Add to ~/.cursor/mcp.json
{
"mcpServers": {
"mcp-cost-tracker-router": {
"command": "npx",
"args": [
"-y",
"mcp-cost-tracker-router"
],
"env": {
"YOUR_API_KEY": "<YOUR_API_KEY>"
}
}
}
}Add to .vscode/mcp.json
{
"servers": {
"mcp-cost-tracker-router": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-cost-tracker-router"
],
"env": {
"YOUR_API_KEY": "<YOUR_API_KEY>"
}
}
}
}Add to ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"mcp-cost-tracker-router": {
"command": "npx",
"args": [
"-y",
"mcp-cost-tracker-router"
],
"env": {
"YOUR_API_KEY": "<YOUR_API_KEY>"
}
}
}
}Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"mcp-cost-tracker-router": {
"command": "npx",
"args": [
"-y",
"mcp-cost-tracker-router"
],
"env": {
"YOUR_API_KEY": "<YOUR_API_KEY>"
}
}
}
}Using several servers? Build one config file with the MCP config generator.
Configuration
YOUR_API_KEYYour API key for the serviceRequired
Tools this server provides (15)
Taken from the project documentation; the running server may differ.
- get_session_cost
- Token totals and USD estimate for the session
- get_tool_costs
- Per-tool cost breakdown
- reset_session
- Start a new tracking session
- record_usage
- Record token usage for a tool call
- set_budget_alert
- Set a USD budget threshold
- suggest_model_routing
- Recommend a model by task type
- check_routing_policy
- Check whether a model is allowed for a task type
- get_spend_history
- Spend by day, week or month
- estimate_workflow_cost
- Pre-run cost estimate for a multi-step workflow
- export_spend_report
- Single-file HTML spend report
- export_budget_audit
- Export the budget decision audit log
- set_project
- Create or update a project and budget
- tag_session
- Tag the session with a project
- get_project_costs
- Cost report for a project
- export_chargeback
- Chargeback report for internal billing
What it does
- Per-tool breakdown
- Shows which tool calls use the most tokens and budget.
- Budget alerts
- Warns at 80% and 100% of a session threshold; optional enforcement.
- Offline token counting
- Uses js-tiktoken with no network call.
- Routing suggestions
- Advises a cheaper model for a task type without enforcing it.
- Spend history
- Aggregates by day, week or month by model or tool.
- Project chargeback
- Tags sessions to projects and exports chargeback reports.
- HTML and audit exports
- Single-file spend report and budget audit log.
Good for
- Seeing which tools burn the most tokens in a long agent session
- Capping spend with a hard session budget
- Allocating AI costs to named projects
- Estimating a multi-step workflow before running it
MCP Cost Tracker Router FAQ
Is prompt content stored?
No. Only token counts, model names and timestamps are stored locally.
Which models are priced by default?
Claude, OpenAI and Gemini models, overridable with --pricing-table.
Does it block overspending?
Only with --enforce-budget, which needs --budget-alert.
Are the costs exact?
They are estimates from a local pricing table and may differ from the provider's invoice.
How do I add MCP Cost Tracker Router to Claude Code?
Run this command in your terminal: claude mcp add mcp-cost-tracker-router --env YOUR_API_KEY='<YOUR_API_KEY>' -- npx -y mcp-cost-tracker-router
What are the best alternatives to MCP Cost Tracker Router?
The closest alternatives to MCP Cost Tracker Router are Budgethelm, ToolRoute, TokenZero, Tokeven Cost Advisor and AI Usage.
Where this comes from
- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.