Offline MCP server that predicts LLM call cost and recommends the cheapest capable model before you call it. No API keys, no network. npx @workswarm/modelcostsaver
ModelCostSaver
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
**Predict the cost of an LLM call before you make it, and pick the cheapest model that still does the job, offline, from your editor.**
ModelCostSaver is a Model Context Protocol server. It gives any AI coding agent or IDE a free, zero-config tool that answers the three questions every agent should ask before an LLM call:
1. **What will this prompt cost on each candidate model?** (predict_cost, estimate_cost)
2. **Which is the cheapest model that meets the task?** (select_optimal_model)
3. **How do my options compare side by side?** (compare_models)
It is pure pricing-and-routing math over a bundled, dated catalog, so the core needs **no API keys and makes no network calls**.
---
Quick start
Run it directly with npx (no install, no keys):
Or write the config for your editor in one command:
**Add to Cursor** — one click installs it in Cursor. Or drop the block below into ~/.cursor/mcp.json, or run npx -y @workswarm/modelcostsaver install --client cursor.
Listed on the official MCP registry and editor MCP directories as io.github.sachinuppal/modelcostsaver.
---
The seven tools
| Tool | What it answers |
|---|---|
| estimate_cost | Cost of one call when you already know (or can estimate) the token counts. |
| predict_cost | Forecast cost across a candidate set from a prompt, before the call. Ranked cheapest-first. |
| select_optimal_model | The cheapest model that meets the task tier, capabilities, and budget, with full reasoning. |
| compare_models | A side-by-side cost table for a fixed token shape, with relativeToCheapest. |
| list_models / get_pricing | The pricing catalog, filterable by provider, tier, capability, or max input price. |
| optimize_request | "I plan to call model X, can I do better?" Returns the cheaper option and the savings. |
| record_usage | Append a local usage record (opt-in; off unless MODELCOSTSAVER_LEDGER=on). |
Every cost-bearing result carries catalogVersion and asOf so you can see how fresh the prices are. Every selection carries a reasoning array, never a black-box pick.
---
Trust: no keys, offline, no telemetry
For a tool that sits in your editor, trust is the whole pitch. ModelCostSaver is:
- **No API keys.** The core does pricing math, not provider calls. Nothing to leak.
- **Offline by default.** The core tools return correct answers with no network access. The only outbound request is an opt-in catalog refresh (MODELCOSTSAVER_REFRESH=on), a single GET of a static JSON, zod-validated before it can replace the bundled catalog, and it always falls back to the bundle on any failure.
- **No telemetry.** Ever. The default is silent and local. record_usage only writes when you set MODELCOSTSAVER_LEDGER=on, and only to a JSONL file under your own config dir.
- **Two dependencies.** @modelcontextprotocol/sdk and zod. Nothing else. Small supply-chain surface, fast npx cold start.
- **Apache-2.0.** An open-source developer tool published by Workswarm as @workswarm/modelcostsaver. The shipped bundle contains no proprietary or internal-service code: no internal-framework imports and no internal identifiers, just dependency-free pricing-and-routing math.
stdout carries only JSON-RPC; all logs go to stderr.
---
Install per IDE
ModelCostSaver speaks stdio MCP, so the entry is the same npx command everywhere. Use install --client to write it idempotently, or paste the block by hand.
Cursor
~/.cursor/mcp.json (global) or .cursor/mcp.json (project):
Claude Code
or a .mcp.json in the repo root (which install --client claude writes):
Claude clients run Claude for their own inference, so the install seeds MODELCOSTSAVER_PROVIDERS=anthropic as a sensible default for target: self recommendations. Override it per call or with the env var. See Self vs code.