# MCP Cost Tracker Router

> MCP Cost Tracker Router is an MCP server for developer tools. Track token spend per tool, set budget alerts and get cheaper-model suggestions. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Platforms:** CLI, self-hosted
- **Repository:** https://github.com/dbsectrainer/mcp-cost-tracker-router
- **MCP Registry name:** io.github.dbsectrainer/mcp-cost-tracker-router
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools), [AI models and LLM tooling](https://ai-powered.com/categories/ai-and-llm)
- **Listing updated:** 2026-11-16

## About

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.

## Features

- **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

## Install

### Claude Code (Terminal)

```sh
claude mcp add mcp-cost-tracker-router --env YOUR_API_KEY='<YOUR_API_KEY>' -- npx -y mcp-cost-tracker-router
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "mcp-cost-tracker-router": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-cost-tracker-router"
      ],
      "env": {
        "YOUR_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "mcp-cost-tracker-router": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-cost-tracker-router"
      ],
      "env": {
        "YOUR_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "mcp-cost-tracker-router": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mcp-cost-tracker-router"
      ],
      "env": {
        "YOUR_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "mcp-cost-tracker-router": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-cost-tracker-router"
      ],
      "env": {
        "YOUR_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "mcp-cost-tracker-router": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-cost-tracker-router"
      ],
      "env": {
        "YOUR_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}
```

## Tools

- `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

## 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.

## Alternatives

- [Budgethelm](https://ai-powered.com/mcp/budgethelm): Budgethelm is a freemium MCP server for developer tools.
- [ToolRoute](https://ai-powered.com/mcp/toolroute): ToolRoute is a freemium MCP server for ai models and llm tooling.
- [TokenZero](https://ai-powered.com/mcp/tokenzero-2): TokenZero is a freemium MCP server for ai models and llm tooling.
- [Tokeven Cost Advisor](https://ai-powered.com/mcp/tokeven-cost-advisor): Tokeven Cost Advisor is a freemium MCP server for ai models and llm tooling.
- [AI Usage](https://ai-powered.com/mcp/ai-usage): AI Usage is an MCP server for developer tools.
- [context-doctor](https://ai-powered.com/mcp/context-doctor): context-doctor is an open-source MCP server for ai models and llm tooling.
- [Agent Toolbox](https://ai-powered.com/mcp/agent-toolbox-2): Agent Toolbox is a freemium MCP server for developer tools.
- [TokenTally by Harlo](https://ai-powered.com/mcp/tokentally-by-harlo): TokenTally by Harlo is a freemium MCP server for ai models and llm tooling.

---
Source: https://ai-powered.com/mcp/mcp-cost-tracker-router
