Llm Cost Estimator

io.github.waqarulwahab由 GitHub 账号 waqarulwahab 发布v0.3.1更新于 Oct 25, 2026

Token counting & multi-model LLM cost estimates: GPT-4o, Claude, Gemini, 25+. No API key.

已验证STDIO仅桌面数据与分析AI 与机器学习

概览

AI 生成的概览

一个本地 MCP 服务器,让助手统计 token 数量并估算 25 种以上大模型的开销,无需 API 密钥。

可以做什么
针对一段文本估算多个模型的 token 数与费用,返回 Markdown 表格和结构化 JSON,可选输出 token 数与货币参数。统计单个模型的 token 数,其中 OpenAI 为精确值,其他提供商标注为估算。列出所有模型键及其提供商、每百万 token 价格和上下文窗口。
适用场景
适合在 GPT-4o、Claude、Gemini、DeepSeek、Mistral、Llama、Grok 等提供商之间比较提示词或输出成本,或在把文本发给模型前确认其 token 消耗量。
运行要求
以 stdio 方式在本地运行,由 MCP 客户端作为子进程启动。需要 Node.js;已发布的 npm 包可用 npx 启动,也可从源码本地构建。无需 API 密钥或环境变量。
安装前请注意
价格被说明为代表性占位值,估算结果应与各提供商官方定价核对。只有 OpenAI 的 token 数是精确的,其他提供商使用 OpenAI 编码近似计算并标注为估算。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Llm Cost Estimator,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

llm-cost-estimator-mcp

An MCP (Model Context Protocol) server that gives Claude, Cursor, or any MCP client the ability to count tokens and estimate LLM costs across GPT-4o, Claude, Gemini, DeepSeek, Mistral, Llama, Grok, and 25+ models — locally, with no API key.

It reuses the exact same tokenizer + pricing + estimator core as the LLM Cost & Token Estimator VS Code extension in this repo.

Tools

ToolDescription
estimate_costToken count + cost across multiple models for a piece of text. Returns a Markdown table and structured JSON. Args: text, models?, outputTokens?, currency?.
count_tokensToken count for one model. Args: text, model?. OpenAI is exact (tiktoken); others are flagged estimates.
list_modelsAll model keys with provider, prices (USD/1M), and context window.

⚠️ Prices are representative placeholders — verify against each provider's official pricing page. OpenAI counts are exact; all other providers are approximated via an OpenAI encoding and flagged as estimates.

Build (from source)

The server reuses the extension's core in ../src (whose files import js-tiktoken), so install the repo-root dependencies first:

bash
npm install            # at the repo ROOT, once (provides the reused core's deps)cd mcp-servernpm installnpm run build          # -> dist/index.jsnpm test               # builds, then runs a real stdio MCP handshake

End users don't need this — they just npx -y llm-cost-estimator-mcp once it's published (the published dist/index.js is fully self-contained).

Connect it

The server speaks MCP over stdio, so any client launches it as a subprocess. Use the absolute path to mcp-server/dist/index.js.

Claude Desktop

Edit claude_desktop_config.json (Windows: %APPDATA%\Claude\claude_desktop_config.json, macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):

jsonc
{  "mcpServers": {    "llm-cost-estimator": {      "command": "node",      "args": ["C:/path/to/llm-cost-estimator/mcp-server/dist/index.js"]    }  }}

Restart Claude Desktop, then ask: "Estimate the cost of this prompt on GPT-4o vs Claude Sonnet vs Gemini."

Claude Code (CLI)

bash
claude mcp add llm-cost-estimator -- node /abs/path/to/mcp-server/dist/index.js

Cursor

Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (per-project):

jsonc
{  "mcpServers": {    "llm-cost-estimator": {      "command": "node",      "args": ["/abs/path/to/mcp-server/dist/index.js"]    }  }}

After publishing to npm (optional)

Once this package is published, clients can launch it without a local build:

jsonc
{  "mcpServers": {    "llm-cost-estimator": { "command": "npx", "args": ["-y", "llm-cost-estimator-mcp"] }  }}

License

MIT — see ../LICENSE.

来源:mcp-server/README.md,提交 b90eb2e

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.3.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分