# mcp-cost-tracker-router [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/dbsectrainer/mcp-cost-tracker-router  
**GitHub Stars:** 0  
**npm Downloads (last month):** 363  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/mcp-cost-tracker-router

## Description
Real-time cost awareness for MCP agent workflows

## Tools
Capabilities this server exposes over MCP:

- **get_session_cost** — Returns token totals and USD cost estimates for the current session. All costs are estimates; verify with your LLM provider's billing dashboard.
- **get_tool_costs** — Returns per-tool cost breakdown for the current session, sorted by cost descending. Useful for identifying the most expensive operations. All costs are estimates.
- **set_budget_alert** — Set a budget threshold in USD. A warning is emitted when session costs reach 80% or 100% of this threshold. Use with --enforce-budget to block calls beyond the limit.
- **reset_session** — Start a new cost-tracking session. Previous session data is retained in history and accessible via get_spend_history.
- **get_spend_history** — Query historical spend aggregated by time period (day/week/month). Returns breakdown by model and tool across all sessions. All costs are estimates.
- **record_usage** — Record token usage for a tool call. Logs LLM API cost estimates into the tracker. Emits a budget warning (notifications/message) if 80% of threshold is reached. Pricing table versions are tracked in CHANGELOG.md.
- **suggest_model_routing** — Heuristic model recommendation by task type. Analyzes the task description and returns a recommended model with reasoning and estimated cost per 1K tokens. Optionally factors in cost constraints.
- **estimate_workflow_cost** — Pre-run cost estimation for a multi-step workflow. Provide a list of tool steps with estimated token counts and models to get total and per-step cost estimates. Output is clearly labeled as ESTIMATE.
- **export_spend_report** — Generate a single-file HTML spend report with session cost breakdown, historical spend by period, model cost comparison chart (CSS bars), and budget status. No external CDN dependencies.
- **export_budget_audit** — Export audit log of budget enforcement decisions. Optionally filter by date range and format as JSON or CSV.
- **set_project** — Create or update a project with an optional budget in USD.
- **get_project_costs** — Get cost report for a project, optionally filtered by a since date.
- **tag_session** — Tag the current session with a project name for cost allocation.
- **export_chargeback** — Generate a chargeback report for internal team billing, grouped by project or session.
- **check_routing_policy** — Check whether a model is allowed for a given task type under the routing policy.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "mcp-cost-tracker-router": {
    "command": "npx",
    "args": ["-y","mcp-cost-tracker-router@latest"]
  }
}
```

## Documentation

## What mcp-cost-tracker-router does

The mcp-cost-tracker-router MCP server adds local cost accounting and model-routing assistance to MCP agent workflows. It estimates token-based spending across Claude, OpenAI, and Gemini models using a configurable pricing table. Usage metadata is stored in a local SQLite database; prompt and response content are not stored.

The server covers four related areas: current-session tracking, budget controls, historical reporting, and project allocation. Session tools show total tokens and estimated cost, rank tools by spend, start a new session, and record usage for individual calls. Project tools associate sessions with named projects and produce project-level cost or chargeback information.

## How it works

Token counts are calculated offline with js-tiktoken, so counting does not require an API request. Costs are estimates based on the local pricing configuration and may differ from a provider invoice. A built-in table includes models from Claude, OpenAI, and Gemini, while a custom JSON pricing file can override individual prices.

Set a session threshold to receive warnings at 80% and 100% of the configured amount. Starting the server with budget enforcement enabled allows calls that would exceed the limit to be blocked. The audit log records budget enforcement decisions for later export.

The routing features are advisory unless budget enforcement is enabled. `suggest_model_routing` accepts a task description and an optional maximum cost, then returns a model recommendation, reasoning, and estimated cost. `check_routing_policy` tests whether a specified model is allowed for a task type.

## Setup and configuration

The mcp-cost-tracker-router MCP server requires Node.js 20.19 or newer and npm. A typical stdio configuration runs the package with `npx` and its `latest` tag. It can also run over Streamable HTTP by supplying an HTTP port, which is intended for sharing one tracking instance across a team.

Relevant command-line options include:

- `--budget-alert` sets the session threshold in USD.
- `--enforce-budget` enables blocking after the threshold; it requires `--budget-alert`.
- `--db` or `--db-path` selects the SQLite file, defaulting to `~/.mcp/costs.db`.
- `--pricing-table` supplies custom model prices.
- `--default-model` sets the fallback model, defaulting to `claude-sonnet-4-6`.
- `--http-port` enables Streamable HTTP instead of stdio.

## Tools and capabilities

The mcp-cost-tracker-router MCP server provides pre-run workflow estimates, daily, weekly, or monthly spend history, and a self-contained HTML spend report. Budget audit data can be exported as JSON or CSV. Chargeback reports can group records by project or session and also support JSON or CSV output.

Sessions can be tagged to projects, and projects may have an optional budget. Read-only reporting tools include current cost, per-tool cost, historical spend, workflow estimates, project costs, spend reports, and audit exports. State-changing tools include usage recording, session reset, budget configuration, project updates, and session tagging.

_Full upstream README: https://allmcps.com/mcp/mcp-cost-tracker-router/readme_

