TokenWise MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
TokenWise: Zero-Dependency LLM & AI Agent FinOps CLI + MCP Server
tokenwise is a lightweight, zero-dependency Python CLI and Model Context Protocol (MCP) server for developers and AI engineers to estimate, audit, and optimize LLM costs across major providers (OpenAI, Anthropic, Google) completely offline.
Features
Zero Dependencies: Runs anywhere with Python 3.9+ using only the Python standard library.
Offline-First: Heuristic tokenization calibrated for modern models, no API keys or proxies required.
Multi-Provider Registry (2025/2026): Supports
gpt-4.1,gpt-4.1-mini,gpt-4.1-nano,o4-mini,gpt-4o,claude-opus-4,claude-sonnet-4,claude-3-7-sonnet,claude-3-5-haiku,gemini-2.5-pro,gemini-2.5-flash,gemini-2.0-flash, and legacy models.Codebase Scanner & CI Gate: Detect expensive/legacy model defaults, missing
max_tokenscaps, and bloated prompts with--markdownPR comments and--fail-on-high.Log Auditor & HTML Executive Report: Audit
JSONL,JSON, orCSVusage logs for spend, model-routing savings,--max-costCI budget gates, and standalone--htmlreports.MCP Server Mode (
tokenwise mcp): Zero-dependency JSON-RPC 2.0 stdio server so AI coding agents (Claude Code, Cursor, Windsurf) can self-check prompt costs before calling frontier models.
Related MCP server: TokenOracle MCP
Installation
pip install tokenwiseFor local/editable installation:
git clone https://github.com/<your-org>/tokenwise.git
cd tokenwise
pip install -e .Usage
1. Estimate Cost for a Prompt
tokenwise estimate --text "How do I optimize my LLM costs?" --output-tokens 1000 --monthly-requests 50000
tokenwise estimate --file prompt.txt --models gpt-4.1 gpt-4.1-mini claude-sonnet-42. Scan a Codebase for Cost Risks
tokenwise scan ./src
tokenwise scan ./src --markdown --fail-on-high3. Audit Usage Logs & Export HTML Report
tokenwise audit usage.jsonl
tokenwise audit usage.jsonl --max-cost 25.00
tokenwise audit usage.jsonl --html finops-report.html4. List Supported Models & Pricing
tokenwise models
tokenwise models --provider anthropic --json5. Run as an MCP Server (Claude Code / Cursor / Windsurf)
Start the stdio server:
tokenwise mcpAdd to your MCP client configuration (e.g., .mcp.json or Cursor MCP settings):
{
"mcpServers": {
"tokenwise": {
"command": "tokenwise",
"args": ["mcp"]
}
}
}Exposed MCP tools: estimate_prompt_cost, scan_codebase_costs, audit_usage_log, list_model_pricing.
6. One-Command CI, MCP & Pre-Commit Setup (tokenwise init)
Scaffold .mcp.json and .github/workflows/tokenwise.yml in any repo:
tokenwise init
tokenwise init --all # Also generates .pre-commit-config.yaml
tokenwise init --mcp --force # Overwrite existing .mcp.jsonOr reference .pre-commit-hooks.yaml directly in .pre-commit-config.yaml via the tokenwise-scan hook.
TokenWise FinOps Team Kit ($19)
Want automated PR cost-risk comments, Slack/Discord daily spend alerts, and an executive LLM model-routing playbook?
Check out the TokenWise FinOps Team Kit (pro_kit/).
Pricing Data
Prices are based on public API list rates and provided for estimation and FinOps auditing purposes.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
See, price, and control every tool call your AI agents make: policy checks, cost, and audit tools.
LLM API prices and AI agent cost estimates, verified daily. Read-only cost lookup tools.
Budget & cost control for AI agents — per-agent spend caps + rate limits before each call.
Sourced LLM API prices and cost budgets for agent runs across OpenAI, Claude, Gemini and more.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to track LLM costs, enforce budgets, compare models, and estimate expenses through simple tool calls.-
- AlicenseNot gradedqualityDmaintenanceEstimates, compares, and controls LLM API costs before agents spend tokens, with tools for cost estimation, model comparison, and budget checking.27 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables LLM clients and coding agents to analyze prompts and recommend the cheapest AI model that meets the task requirements across text, voice, video, and other modalities, projecting monthly cost savings against a flagship baseline.1MIT
- AlicenseNot gradedqualityDmaintenanceProvides coding agents with pre-flight cost estimation by analyzing local logs to forecast token usage and quota impact before expensive work, exposing tools for remaining quota, per-task cost estimates, and attempt affordability.MIT