
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 分