A Model Context Protocol (MCP) server that monitors every MCP plugin installed in Claude Desktop or Claude Code, counts their token usage, measures execution time, estimates USD cost, and exports a beautiful interactive HTML dashboard powered by Plotly + Pandas.
The generated report is a self-contained HTML file (no server needed) that opens directly in your browser with:
- KPI cards — total tokens, session tokens (24h), calls, estimated cost, avg duration
- Interactive charts — horizontal bar, input/output donut, calls pie, timeline
- Detailed table — per-plugin breakdown with installation date, first/last seen, session tokens, and cost
- 🔍 Search menu — filter plugins instantly in both tables
- Installed plugins inventory — all discovered servers and their sources
| Feature | Description |
|---|---|
| 🔍 Plugin Scanner | Reads claude_desktop_config.json + project .mcp.json files |
| 🧮 Token Counting | Uses tiktoken (cl100k_base) — same encoding as Claude / GPT-4 |
| 💰 Cost Estimation | Configurable per-token pricing (input / output separately) |
| ⏱️ Duration Tracking | Records wall-clock time per tool call in milliseconds |
| 📅 Install Date | Shows when each plugin was installed (config file mtime) |
| 🕐 First / Last Seen | Tracks first and last usage datetime per plugin |
| 🟢 Session Tokens | Highlights tokens consumed in the last 24 hours |
| 📊 HTML Dashboard | Single-file report with Plotly charts, opens automatically |
| 🗄️ Persistent Storage | Usage data saved to ~/.mcp-tracker/usage.json |
| 🧹 Reset Tool | Clear all data with a single command |
savetokens4claude/
├── server.py # MCP server — exposes 5 tools to Claude
├── tracker.py # Token counting & JSON persistence layer
├── config_reader.py # Discovers installed MCP servers from configs
├── report_generator.py # Builds the interactive HTML dashboard
├── install.py # One-command auto installer
└── requirements.txt # Python dependencies
~/.mcp-tracker/
├── usage.json # All recorded tool-call sessions
└── report.html # Latest generated dashboard
python3 <(curl -fsSL https://raw.githubusercontent.com/BRUNEXX13/savetokens4claude/blog/install.py)python (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/BRUNEXX13/savetokens4claude/blog/install.py" -UseBasicParsing).ContentThe installer will automatically:
- Clone this repository to
~/savetokens4claude - Create an isolated Python virtual environment
- Install all dependencies
- Register
mcp-save-tokens-4-claudein your Claude config
Then restart Claude Desktop (or reopen Claude Code) — and you're done. 🎉
python3 ~/savetokens4claude/install.py --uninstallpython3 <(curl -fsSL https://raw.githubusercontent.com/BRUNEXX13/savetokens4claude/blog/install.py) --dir ~/tools/savetokens4claudeOnly needed if you prefer to set things up yourself.
- Python 3.11+
- Claude Desktop or Claude Code (CLI)
- git and pip
git clone --branch blog https://github.com/BRUNEXX13/savetokens4claude.git ~/savetokens4claude
cd ~/savetokens4claudepython3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtOpen your config file:
| OS | Path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
Add the entry inside "mcpServers":
{
"mcpServers": {
"mcp-save-tokens-4-claude": {
"command": "/home/your-user/savetokens4claude/.venv/bin/python3",
"args": ["/home/your-user/savetokens4claude/server.py"]
}
}
}Windows: use
pythonand escape backslashes:"C:\\Users\\you\\savetokens4claude\\.venv\\Scripts\\python.exe"
Restart Claude Desktop — done.
Create a .mcp.json file in your project root:
cat > /path/to/your-project/.mcp.json << EOF
{
"mcpServers": {
"mcp-save-tokens-4-claude": {
"command": "/home/$USER/savetokens4claude/.venv/bin/python3",
"args": ["/home/$USER/savetokens4claude/server.py"]
}
}
}
EOFThen open Claude Code inside your project:
cd /path/to/your-project
claudeClaude Code detects .mcp.json automatically — no restart needed.
Once registered, Claude can call these tools on your behalf:
Lists every MCP server discovered in Claude Desktop's global config and any project-level .mcp.json files.
Example output:
🔌 5 MCP plugin(s) installed:
• github-mcp
Command : npx -y @modelcontextprotocol/server-github
Source : desktop
• filesystem-mcp
Command : npx -y @modelcontextprotocol/server-filesystem /home
Source : desktop
Records a tool invocation. Call this after using any other MCP tool to log it.
| Parameter | Type | Description |
|---|---|---|
plugin_name |
string | Name of the MCP server (e.g. "github-mcp") |
tool_name |
string | Name of the specific tool used |
input_data |
object | Parameters sent to the tool |
output |
string | Text response returned by the tool |
duration_ms |
number | Elapsed time in milliseconds |
Example output:
✅ Call recorded:
Plugin : github-mcp
Tool : search_repos
Tokens : 742 (in 128 / out 614)
Duration : 1 203.4 ms
Cost est.: $0.009594 USD
Generates the full HTML dashboard and opens it in your default browser.
| Parameter | Type | Default | Description |
|---|---|---|---|
open_browser |
boolean | true |
Open the report automatically |
Example output:
📊 Dashboard generated successfully!
File : /home/you/.mcp-tracker/report.html
Sessions : 180
Plugins : 5
Browser : opened automatically ✓
Open manually on Linux:
xdg-open ~/.mcp-tracker/report.htmlReturns a quick plain-text summary without generating the full report.
Example output:
📈 Usage Summary
Total tokens : 128,450
Total calls : 180
Estimated cost: $1.2034 USD
By plugin:
• browser-mcp : 42,310 tokens | 63 calls | 189.4s
• github-mcp : 38,902 tokens | 54 calls | 87.2s
• postgres-mcp : 25,680 tokens | 31 calls | 44.8s
Permanently erases all recorded usage data from ~/.mcp-tracker/usage.json.
⚠️ This action cannot be undone.
1. Open Claude Code inside your project (cd your-project && claude).
2. Ask Claude to use any MCP tool (search GitHub, query a DB, read a file, etc.).
3. After the response, ask Claude to call track_call to log the usage.
4. Repeat throughout your session.
5. When ready, ask Claude to generate_report — the dashboard opens automatically.
Example prompt:
Use github-mcp to search for Python MCP servers.
After you get the result, track the call with track_call.
When done, generate the token usage report.
⚠️ Claude Code tip: If you have other plugins/skills installed, typing generic phrases likescan my pluginsmay trigger them instead of this plugin. To call your tools directly, always be explicit:use the mcp-save-tokens-4-claude scan_plugins tool call scan_plugins from mcp-save-tokens-4-claude call generate_report from mcp-save-tokens-4-claude call get_stats from mcp-save-tokens-4-claude call track_call from mcp-save-tokens-4-claude
Edit tracker.py:
# USD per 1 000 tokens — adjust to match your actual model pricing
INPUT_COST_PER_1K = 0.003
OUTPUT_COST_PER_1K = 0.015Edit server.py:
REPORT_PATH = Path.home() / ".mcp-tracker" / "report.html"Claude Desktop / Claude Code (CLI)
│
│ stdio (MCP protocol)
▼
┌──────────────────────┐ reads ┌─────────────────────┐
│ server.py │◄─────────►│ config_reader.py │
│ (mcp-save-tokens- │ │ (plugin discovery) │
│ 4-claude) │ └─────────────────────┘
└──────────┬───────────┘
│ log / read
▼
┌─────────────────┐ aggregates ┌──────────────────────┐
│ tracker.py │─────────────►│ report_generator.py │
│ (storage) │ │ (Plotly dashboard) │
└─────────────────┘ └──────────┬───────────┘
~/.mcp-tracker/ │
usage.json ▼
report.html (browser)
| Package | Purpose |
|---|---|
mcp |
Model Context Protocol SDK — server transport & tool API |
tiktoken |
Token counting with cl100k_base encoding |
pandas |
Data aggregation and transformation |
plotly |
Interactive chart generation |
Contributions are welcome! Ideas for future improvements:
- Auto-intercept proxy mode (wrap other MCP servers transparently)
- SQLite backend for larger datasets
- Cost alerts / budget thresholds
- Export to CSV / Excel
- Claude Code plugin marketplace listing (
.claude-plugin/marketplace.json) - GitHub Actions CI
To contribute:
git clone --branch blog https://github.com/BRUNEXX13/savetokens4claude.git
cd savetokens4claude
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# make your changes, then open a pull requestMIT — see LICENSE for details.