
Modelcostsaver
io.github.sachinuppal由 GitHub 帳號 sachinuppal 發布v0.1.1更新於 Oct 24, 2026
Offline MCP: predict LLM call cost and pick the cheapest capable model. No keys, no network.
概覽
離線 MCP 伺服器,依內建且附日期的定價目錄預測 LLM 呼叫成本,並推薦最便宜又夠用的模型。
- 可以做什麼
- 估算或預測提示詞在各候選模型上的成本,並依價格由低到高排序
- 依任務層級、能力與預算挑出最便宜的可用模型,並附上推理說明
- 在固定 token 規模下並排比較模型,並算出改用其他模型可省下的費用
- 依供應商、層級、能力或最高輸入價格瀏覽定價目錄
- 可選擇將用量紀錄附加到本機 JSONL 帳本
- 適用情境
- 適合在實際發出 LLM 呼叫前想先了解費用,或在多個模型間依價格做選擇的開發者與編碼代理。也適合希望零設定、離線取得定價建議、而不串接真實供應商的編輯器環境。
- 執行需求
- 以 stdio 方式在本機執行,通常透過 npx 呼叫已發佈的 npm 套件,因此需要 Node.js。不需 API 金鑰或帳號,核心工具在沒有網路時也能正常回傳結果。所有設定皆為選用,可透過環境變數或設定檔調整。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Modelcostsaver,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
ModelCostSaver
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.
[No API keys] [Offline by default] [No telemetry] [License] [Dependencies]
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:
- What will this prompt cost on each candidate model? (
predict_cost,estimate_cost) - Which is the cheapest model that meets the task? (
select_optimal_model) - 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
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_usageonly writes when you setMODELCOSTSAVER_LEDGER=on, and only to a JSONL file under your own config dir. - Two dependencies.
@modelcontextprotocol/sdkandzod. Nothing else. Small supply-chain surface, fastnpxcold 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 <name> 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.
Claude Desktop
Add the same mcpServers block to claude_desktop_config.json.
VS Code / GitHub Copilot
.vscode/mcp.json:
Windsurf
~/.codeium/windsurf/mcp_config.json with the same mcpServers block, or:
Cline / Zed / Antigravity
Same stdio command/args. Use the matching installer:
After adding the server, restart the client and confirm the seven tools appear in the tool list.
Two axes: self vs code
ModelCostSaver advises; it does not route traffic. So every recommendation is filtered to what you can actually act on, along two independent axes.
Axis 1, availability. Recommendations are scoped to a set of allowed providers. The default is derived from the connected client (read from the MCP handshake): a Claude client defaults to anthropic because its own inference is Claude; multi-provider clients (Cursor, VS Code, Windsurf, Cline, Zed, Antigravity) and unknown clients default to all providers. The scope and its source are always echoed in reasoning, and it is overridable: a per-call providers arg, then MODELCOSTSAVER_PROVIDERS, then config, then the client default, then all.
Axis 2, target.
target: 'self'(default): the agent's or your own next inference in this client. The Axis-1 scope applies. In Claude Code this means cross-tier Anthropic moves (Opus to Haiku), which you can act on right now.target: 'code': a model you will call from your own application, where you supply that provider's key. The client scope does not apply, so all in-catalog providers are eligible.
ModelCostSaver is always honest about the gap: if the globally-cheapest model is outside your actionable set, it is surfaced as cheaperIfAvailable with the reason, never silently chosen. For example, a Claude Code target: self summarize call selects claude-haiku-4-5 and notes that a cheaper non-Anthropic model exists if you pass target: code.
How it predicts
- Tokens. Exact counts if you supply them; otherwise a heuristic estimate (
~4 chars/token, tunable viaMODELCOSTSAVER_CHARS_PER_TOKEN). The heuristic is approximate but common-mode across candidates, which is what relative ranking needs. Output tokens come from your explicit value, then the task class cap, then the model cap, then a conservative default. - Cost.
(inTok / 1e6) * inputPerMillion + (outTok / 1e6) * outputPerMillion, in full-precision USD and as integerusdMicros. A prediction is never rounded to cents. - Selection. Resolve the target tier (from an explicit
taskClass, else a transparent keyword/length classifier), filter candidates by tier (degrade up, never below the floor), capabilities, and provider scope, forecast each, drop those over budget intorejected, and pick the cheapest survivor. Every step is recorded inreasoning, and afallbackChainis returned for retry-on-failure.
Configuration
All config is optional. Precedence: tool-call arg, then env var, then modelcostsaver.config.json (cwd, then your user config dir), then the built-in default.
Pricing data
Prices change often, so ModelCostSaver ships a versioned, dated seed and is honest about its freshness.
- The bundled
catalog.jsoncarries acatalogVersion, anasOfdate, and asourceon every entry. - Default behavior is offline: it reads only the bundled catalog.
MODELCOSTSAVER_REFRESH=onfetches a single static JSON, validates it with zod, caches it with a TTL, and falls back to the bundle on any failure.- A
pricingOverridesmap inmodelcostsaver.config.jsonlets you inject negotiated or enterprise rates without forking.
Verify before you trust a number for billing. The seed is re-checked against each provider's public pricing page at release; the asOf date tells you when. For absolute precision in your own accounting, confirm against your provider invoice.
Development
License
Apache-2.0. See NOTICE.
來源:README.md,提交 37346c1
工具
0版本歷史
1- v0.1.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分