tokcalc MCP Server

io.github.stevecrates489-commits由 GitHub 账号 stevecrates489-commits 发布v0.3.4更新于 Oct 25, 2026

LLM serving capacity planner: VRAM, KV cache, GPU topology, latency, and cost.

已验证Streamable HTTP可网页运行云端与基础设施数据与分析AI 与机器学习

概览

AI 生成的概览

LLM 服务容量规划器,让助手针对模型与负载估算显存、KV 缓存、GPU 拓扑、延迟和成本。

可以做什么
查询支持的模型、GPU 与量化 ID 以及精选的 MLPerf 参考配置,并将模型目录条目与 HuggingFace 上的实际配置文件比对,本地缓存 24 小时并支持离线回退。估算单个配置的容量:显存与 KV 缓存明细、吞吐与延迟区间、并发数、成本、置信度、假设与来源。针对同一负载比较 GPU 与云 SKU,并推荐拓扑,必要时包含张量并行与上下文并行。比较按 token 计费的 API 月成本与自建 GPU 基础设施,并执行反向搜索,返回按成本、吞吐或性价比排序的可行 GPU 与拓扑配置。
适用场景
适合在规划或评审 LLM 部署时使用:估算 GPU 与内存规模、在 API 与自建之间取舍,或回答某模型在给定上下文长度和并发下是否放得下。它面向设计评审和部署前决策,而不是运行或监控线上服务。
运行要求
可作为远程端点使用,也可作为本地 npm 包通过 npx 启动,后者需要 Node.js。托管端点需要 bearer API 密钥,通过填写邮箱获取;本地 stdio 安装无需密钥。自托管 HTTP 模式使用 MCP_API_KEY、UPSTASH_REDIS_REST_URL 和 UPSTASH_REDIS_REST_TOKEN 环境变量进行鉴权和限流。获取模型规格需要访问 HuggingFace 的网络连接。
安装前请注意
所有估算都是规划预测,不构成部署保证。托管端点有限流,密钥在 90 天不活动后过期。record_measured 工具会写入校准状态,从而改变该模型、GPU 与量化组合之后的估算结果;其余工具为只读。README 说明开源计算器之外还有付费云服务层。

安装

在 SourceWeft 中

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

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/io.github.stevecrates489-commits%2Ftokcalc/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。

{
  "mcpServers": {
    "tokcalc": {
      "type": "http",
      "url": "https://tokcalc.vercel.app/api/mcp"
    }
  }
}

README

tokcalc

The open-source LLM serving capacity planner

Plan your LLM deployment before you rent the GPUs.

[Live demo] [License: Apache 2.0] [PRs welcome] [Made with Next.js] [MCP server]


[tokcalc demo]

Switch model → multi-GPU → long-context capacity planner → Build vs Buy → Reference catalog → Live GPU pricing


tokcalc turns your LLM traffic, context length, latency SLOs, cache behavior, and model choice into a defensible serving topology and cost plan — with transparent formulas and cited benchmarks.

It's the engineering-grade pre-deployment decision layer for LLM inference. Not another static "tokens per second" calculator.

Try it now

tokcalc.vercel.app — no signup, no tracking, no paywall.

tokcalc is an open-source LLM serving capacity planner with 44 models, 31 accelerators, and 16 quantization formats. It estimates model fit, KV/state memory, throughput, latency, topology, and cost through a shared catalog and calculation engine used by the website, the MCP server, and the CLI.

Pick a model, a GPU, and a workload. Get an instant capacity plan:

  • Generation speed (tok/s)
  • Estimated first-token latency + inter-token latency (ITL)
  • VRAM budget with KV-cache sizing
  • Multi-GPU topology recommendation (Single GPU → TP×2/4/8 → Context Parallel)
  • Monthly cost + break-even vs API pricing
  • Live GPU pricing across Azure + AWS + GCP + Vast.ai marketplace (fetched in parallel)
  • Shareable URL — your config encoded in the URL hash, send to colleagues
  • Copy as Markdown — paste the full result into GitHub issues / Slack / docs

GitHub Action — plan on every PR

If your repo declares a serving plan, tokcalc can check it. Drop a .tokcalc.json at the repo root:

json
{  "model": "llama3-70b",  "gpu": "h100-sxm",  "quantization": "fp8",  "numGpus": 2,  "contextTokens": 32768,  "concurrency": 16}

Then add this to .github/workflows/plan.yml:

yaml
name: tokcalcon:  pull_request:    paths: [".tokcalc.json"]
jobs:  plan:    runs-on: ubuntu-latest    steps:      - uses: stevecrates489-commits/[email protected]        with:          fail-on-infeasible: true

Every PR that touches the plan gets a comment with the VRAM budget, KV-cache sizing, throughput, TTFT/ITL, and cost — so a reviewer can check the model/GPU choice without leaving the diff.

Pin to a release tag (as above) rather than @main, so the action can't change under you between runs.

The action runs tokcalc's own src/lib/token-calc.ts from this repository, so the numbers it reports are the same ones the site and the MCP tools produce. There is no second implementation to drift.

Any field can be overridden per-run, or you can skip the config file entirely:

yaml
- uses: stevecrates489-commits/[email protected]  with:    model: mixtral-8x7b    gpu: h200-sxm    quant: fp8    gpus: 2    context: 32768    concurrency: 32

Run the same thing locally without the action:

bash
npx @tokcalc/mcp-server plan --config .tokcalc.jsonnpx @tokcalc/mcp-server plan --model llama3-70b --gpu h100-sxm --quant fp8 --format json

Exit code is 0 when the plan fits, 2 when it does not, 1 on a usage error — so it works as a CI gate.

Why tokcalc?

The market has dozens of "tokens per second" calculators and self-host-vs-API break-even tools (induwara.lk, gigagpu, kickllm, cloudparity, curlscape, profitable.ai). None of them are unified capacity planners — and none show their math.

What tokcalc answers that competitors can't

"Can I serve Qwen 2.5 72B at 128K context on 2× H100 with 20 concurrent users?"

"How many H200s do I need for 1,000 req/min with P95 TTFT < 2s?"

"Does FP8 or AWQ save more money once quality, KV cache, and engine support are included?"

"At what daily volume does an H100 beat GPT-4o pricing?"

"What's the cheapest H100 right now across Azure / AWS / GCP / Vast.ai?"

"What happens to cost and latency if an agent makes 8 model calls, has 3 tool calls, and its context grows by 5K tokens each turn?"

"Would prefix caching, continuous batching, or PD disaggregation save more for this workload?"

Features

Calculator tab

FeatureWhat it computes
Model fit / VRAMWill the model + KV cache fit in the GPU's memory?
ThroughputDecode tok/s (per-stream) + aggregate (batched) + prefill tok/s
Latency splitTime-to-first-token (= prefill) + inter-token latency (= decode)
Continuous batchingUser-tunable 1.0–4× multiplier (cited 1.5–4× SOSP range)
Reasoning tokensHidden reasoning budget added to billed output (o1 / R1 / Claude thinking)
Prompt cachingSelf-hosted vLLM APC + Anthropic 5m/1h TTL + OpenAI 50%-off cached tokens
Speculative decodingUser-tunable 1.2–4× boost factor
Multi-GPU TP1× → 8× tensor parallel with NVLink efficiency factor
Long-context capacityKV memory + max concurrency + prefill time at 4K → 1M context
Topology recommendationSingle GPU → TP×2 → TP×4 → TP×8 → TP×8 + Context Parallel (RingAttention)
Cost economicsGPU $/hr → $/M output tokens → $/request → monthly cost
Observed benchmark calibrationPaste vLLM/SGLang/TRT-LLM JSON → see formula accuracy verdict (validated / underestimated / overestimated)

Build vs Buy tab

Independent calculator (separate state) that compares:

  • Self-host: model + GPU + quant + utilization + batch → $/M tokens + monthly cost
  • API: 13 providers (OpenAI / Anthropic / Gemini / Groq / DeepSeek / Mistral / Together)
  • Verdict: Self-host cheaper / API cheaper / Not enough volume — with break-even reqs/day

Reference tab

A tab on the homepage (tokcalc.vercel.app → Reference), not a separate route. 6 sub-tables — fully transparent, every record source-linked where available:

  • Models (44 entries: Llama 4 Scout/Maverick, Qwen 3 family, DeepSeek V3/R1, Pixtral, BGE-M3, GPT-OSS 20B/120B, Kimi K3, GLM-5.3, ...)
  • Accelerators (31 entries: H100/H200/B200/B300, AMD MI300X/MI325X, Intel Gaudi 3, TPU v5p/Trillium, Groq LPU, Cerebras WSE-3, Apple M2/M3/M4 Ultra, ...)
  • Quantization (16 formats: FP16/BF16, GGUF Q2_K→Q8_0, GPTQ, AWQ, EXL2, FP8, NVFP4)
  • API pricing (13 models with input/cached/output + retired/current status)
  • Cloud GPU pricing (all accelerators with $/hr > 0 + typical providers — static curated)
  • 🔴 Live pricing (real-time fetch from Azure + AWS + GCP + Vast.ai in parallel — LIVE badges + timestamps)

The long-context capacity planner (the differentiator)

This is the formula the Perplexity research brief called "the most important tokcalc should visibly expose":

$$ \text{KV bytes/request} = 2 \cdot L \cdot T \cdot H_{\text{kv}} \cdot D_h \cdot B $$

For dense attention, prefill cost grows superlinearly with context length:

$$ \text{prefill FLOPs} = \underbrace{2 \cdot N \cdot T}{\text{linear}} + \underbrace{T^2 \cdot H{\text{kv}} \cdot D_h \cdot L}_{\text{attention}} $$

tokcalc shows you:

  • Max concurrent users at 4K / 8K / 16K / 32K / 64K / 128K / 256K / 512K / 1M context
  • KV memory per request at each context length
  • Prefill time (with superlinear attention correction beyond 32K)
  • Required topology (Single GPU → TP×2/4/8 → TP×8 + Context Parallel)
  • RingAttention citation when CP is needed

Live GPU pricing (NEW)

The 🔴 Live pricing sub-tab in Reference fetches real-time GPU prices from 4 providers in parallel via Promise.allSettled:

ProviderAPIAuthCache TTL
AzureRetail Prices APINone (public)24h
AWSEC2 bulk pricing fileNone (public)24h
GCPCloud Billing Catalog APIGCP_API_KEY env var24h
Vast.aiMarketplace bundles APINone (public)5m (spot prices change rapidly)

Each provider shows a LIVE badge with timestamp + cache state. The comparison table shows the cheapest price per GPU across all 4 providers (highlighted in emerald) + per-provider breakdown.

If any provider fails (e.g., GCP_API_KEY not set), the others still work — graceful degradation per provider.

The math, transparently

Every number above comes from a formula you can inspect. No black boxes.

Decode tokens/sec (memory-bandwidth bound)

$$ \text{decode tok/sec} \approx \frac{\text{HBM BW} \cdot \eta_{\text{mem}} \cdot \text{quant_eff}}{\text{model size}} $$

Where:

  • HBM BW = GPU memory bandwidth (e.g., 3350 GB/s for H100 SXM)
  • η_mem = 0.65 = typical real-world memory utilization (35% overhead)
  • quant_eff = dequantization efficiency multiplier (1.0 for FP16, 1.5 for FP8 on H100, 0.85 for INT4)
  • model size = active_params × bytes_per_param (uses ACTIVE params for MoE, not total)

Refs: PagedAttention paper (arxiv.org/abs/2309.06180)

Prefill tokens/sec (compute bound)

$$ \text{prefill tok/sec} \approx \frac{\text{GPU FLOPS} \cdot \eta_{\text{compute}}}{2 \cdot \text{active params}} $$

Where:

  • GPU FLOPS = dense FP16/BF16 TFLOPS (sparse values not used)
  • η_compute = 0.50 = typical compute utilization
  • Factor of 2 = one multiply + one add per parameter per token

For long context (>32K), the superlinear attention correction above applies.

Continuous batching multiplier (workload-specific)

$$ \text{aggregate tok/sec} = \text{decode tok/sec} \cdot \text{batch size} \cdot \text{continuous batching multiplier} $$

Critical caveat: There is no universal continuous batching multiplier. vLLM reported 14–24× vs HF Transformers (extreme), 2.2–2.5× vs TGI. SOSP paper finds 2–4× typical vs FasterTransformer/Orca. tokcalc defaults to a conservative 1.5× and lets you tune.

Refs:

Prompt caching economics (Anthropic / OpenAI)

For shared prefix of length $T_p$, suffix of length $T_u$, output $O$, cache hit rate $h$:

$$ \text{API input cost} = N \cdot \left[ (1-h) \cdot T_p \cdot P_{\text{write}} + h \cdot T_p \cdot P_{\text{read}} + T_u \cdot P_{\text{input}} \right] $$

Anthropic multipliers (verified 2025-2026):

  • 5-minute cache write: 1.25× base input
  • 1-hour cache write: 2.0× base input
  • Cache read: 0.1× base input (90% savings)

OpenAI: cached input discounted 50%, no separate write fee.

Refs:

Multi-GPU topology recommendation

$$ \text{total needed} = \text{model weights} + (\text{KV per request} \cdot \text{batch size}) $$

Walk the smallest topology that fits:

  • Single GPU: total ≤ VRAM × 1
  • Tensor Parallel ×2/4/8: total ≤ VRAM × N (weights + KV split evenly)
  • TP×8 + Context Parallel: total > VRAM × 8 — use RingAttention to shard KV across nodes

Refs: RingAttention paper

Self-host vs API break-even

$$ \text{self-host $/M tokens} = \frac{\text{GPU $/hr}}{3600 \cdot \text{effective tok/s} \cdot \text{utilization}} \cdot 10^6 $$

$$ \text{break-even req/day} = \frac{\text{monthly self-host cost}}{30 \cdot \text{API cost per request}} $$

The decisive term is effective utilization — not peak throughput. A GPU running at 10% utilization pays 10× more per token than the theoretical minimum.

Comparison with adjacent tools

Capabilityinduwara / techfuelhq / pcmasterstudiogigagpu / kickllm / cloudparityHF Open LLM Leaderboard / MLPerftokcalc
Model × accelerator × quant tok/s✓somesome✓
Model-fit / VRAMbasicrarerare✓
KV-cache by context + concurrency——implicit✓
Prefill vs decode split (TTFT/ITL)——engine-specific✓
Continuous batching / paged attention——docs only✓
Long-context (128K–1M) planning———✓
Topology recommendation (TP/CP)——partial✓
Prompt-cache economics—partial API only—✓
Reasoning tokens (o1/R1/Claude thinking)———✓
API vs self-host break-evensome✓—✓
Live cloud GPU pricing (4 providers)———✓
Observed benchmark calibration———✓
MCP server for AI agents———✓
Public hosted MCP endpoint + self-serve keys———✓
Transparent formulas / open sourcemixedusually nomixed✓
Cited benchmark evidence per configrarerare✓ (not planning)✓ (in progress)
Shareable URL per config———✓
Copy result as Markdown———✓

Roadmap

Shipped

  • ✅ 44 models, 31 accelerators, 16 quantization formats
  • ✅ Continuous batching, reasoning tokens, prompt caching
  • ✅ Estimated first-token latency / ITL split, long-context superlinear attention
  • ✅ Long-context capacity planner + topology recommendation
  • ✅ Build-vs-Buy calculator (13 API providers with retired/current status)
  • ✅ Reference catalog (6 sub-tables including live pricing)
  • ✅ Live GPU pricing (Azure + AWS + GCP + Vast.ai parallel fetch with LIVE badges)
  • ✅ Observed benchmark calibration (paste vLLM/SGLang/TRT-LLM JSON → verdict)
  • ✅ MCP server v0.3.4 — 10 read-only tools + 1 calibration writer, stdio + Streamable HTTP transports
  • ✅ Single-core MCP architecture — one src/lib/mcp/core.ts, shimmed into both the hosted endpoint and the npm package, so the two surfaces cannot drift
  • ✅ Published to the MCP Registry and kept current by an OIDC workflow on every v* tag
  • ✅ Correct MoE accounting — resident (full) weights and active (per-token) parameters reported separately, instead of conflating them
  • ✅ Strict tool schemas — Zod 4 native JSON Schema; unknown parameters are rejected with the valid names suggested back
  • ✅ Public hosted MCP endpoint at tokcalc.vercel.app/api/mcp with bearer auth + Upstash Redis rate limiting
  • ✅ Self-serve API key generation at tokcalc.vercel.app/mcp (email → instant key)
  • ✅ 4 SEO landing pages: /compare/h100-vs-h200, /compare/gguf-q4-k-m-vs-q5-k-m, /self-host-vs-openai-api, /mcp (install docs)
  • ✅ Share URL + localStorage persistence
  • ✅ GitHub Action — drops a capacity + cost plan straight onto your PR
  • ✅ Copy result as Markdown (for GitHub issues / Slack / docs)
  • ✅ Dark mode toggle
  • ✅ Plain-English glossary (28 terms with hover tooltips)
  • ✅ OG image + Twitter card + social metadata
  • ✅ Plausible Analytics (privacy-friendly) + Sentry error monitoring

Next 30 days

  • ⏳ Versioned price + benchmark provenance — source URL + retrieval date on every rate and benchmark
  • ⏳ P/D disaggregation planner (separate prefill + decode pools)
  • ⏳ Engine-aware presets (vLLM / SGLang / TensorRT-LLM / llama.cpp) — UI integration
  • ⏳ Multi-turn / agentic economics — growing context and tool-call turns in the cost model

Next 90 days

  • ⏳ Multi-LoRA capacity planner (Punica / S-LoRA economics)
  • ⏳ VLM image-token accounting (per-model patch/tile tokenization)

Deliberately not doing

  • i18n (Chinese / Japanese / Korean) — permanent translation maintenance across 44 models × 31 accelerators × 11 tools, and traffic is currently overwhelmingly CI and agent installs rather than human readers. Revisit only if CJK traffic shows up in analytics.
  • OAuth 2.1 / PKCE — auth infrastructure for a product with one user. Self-serve key issuance plus Upstash rate limiting already covers the real need. Revisit on demand.
  • Training/fine-tuning FLOPs, energy/carbon, embedding mode — each of these is a separate product in a separate domain. "Capacity planner" is a sharp position; widening it into a general AI-infra calculator suite costs more than it earns.

Open core model

tokcalc is open core — the calculator and catalog are open source; the cloud/data/team features are paid.

AssetLicenseNotes
Source codeApache 2.0This repo. Free to use, modify, distribute
Model/GPU/quant catalogCC0 1.0Public domain data. Anyone can use, no attribution required
Benchmark provenance dataCC-BY-SA 4.0Anyone can use, but must attribute + share-alike
DocumentationCC-BY 4.0Attribution required if copied
"tokcalc" name + logoTrademarkEven without formal registration, common-law rights apply
Cloud SaaS layerProprietaryReal-time pricing API, benchmark DB, team workspaces (coming soon)

Why this structure

  • Trust: Open-source formulas build credibility vs opaque competitors
  • Community: Contributors can submit models, accelerators, quants, benchmarks
  • Defensibility: Trademark + cloud features + URL-share viral loop protect against forks
  • Revenue: Cloud tier funds ongoing development + pricing/benchmark data maintenance

Contributing

We welcome contributions! See CONTRIBUTING.md for:

  • How to add a model (with HuggingFace config.json as source)
  • How to add an accelerator (with critical guardrails for B200/B300 null FP16 fields)
  • How to add a quantization format (with measured file sizes as source)
  • How to submit a benchmark (3-tier confidence model)
  • How to improve a formula (cite the source, no magic numbers)

Most-needed contributions

  • 🟢 New models (Qwen 3, Mistral Large 4, Llama 4 variants as they release)
  • 🟢 New accelerators (B300, AMD MI400, Apple M5 Ultra when shipping)
  • 🟢 New quantization formats (mxFP8, MXFP4, BitNet 2)
  • 🟢 Real benchmark data (run vLLM benchmarks and submit with provenance)
  • 🟢 Translations (especially Chinese, Japanese, Korean)

MCP server — use tokcalc from AI agents

tokcalc ships an MCP (Model Context Protocol) server that lets AI agents (Cursor, Claude Desktop, Cline) call tokcalc during design reviews.

npm package: @tokcalc/mcp-server (latest: v0.3.4) Public endpoint: https://tokcalc.vercel.app/api/mcp (Streamable HTTP, bearer auth, rate-limited) Install docs: https://tokcalc.vercel.app/mcp

11 tools — 10 read-only + 1 calibration writer

ToolWhat it doesAccess
estimate_capacityVRAM/KV/throughput/latency/cost for one configread-only
compare_gpusRanked accelerator comparison for one workloadread-only
recommend_topologyTP/CP topology recommendationread-only
estimate_api_vs_self_hostBreak-even analysisread-only
list_modelsDiscover supported model IDsread-only
list_gpusDiscover supported accelerator IDsread-only
get_mlperf_benchmarksCurated MLPerf Inference v4.1 audited reference configsread-only
find_config_for_sloInverse planner — SLOs + traffic → feasible configs ranked by cost/throughput/valueread-only
plan_deploymentOne-call decision brief — memory + perf + build-vs-buy + risks + next stepsread-only
fetch_model_specDiff the catalog against live HuggingFace config.json (24h cache)read-only
record_measuredStore real tok/s measurements; future estimates self-calibratewrites state

The ten planning tools have no side effects, no cloud credentials, no deployments. record_measured is the one writer: it stores a measurement so later estimates for that model+GPU+quantization can self-calibrate. Every tool declares this in the MCP wire annotations (readOnlyHint / destructiveHint / idempotentHint / openWorldHint), so a client can tell a read from a write before calling it.

Tool parameters are strict — unknown keys are rejected rather than ignored, and the error names the valid ones. The parameters are model and gpu (not modelId / gpuType).

Option A: Public hosted endpoint (recommended — no install)

Point Cursor or Claude Desktop at the public endpoint. Get an instant API key at /mcp:

json
{  "mcpServers": {    "tokcalc": {      "url": "https://tokcalc.vercel.app/api/mcp",      "headers": { "Authorization": "Bearer <your-api-key>" }    }  }}

Features:

  • ✅ Bearer API key auth (constant-time comparison via crypto.timingSafeEqual)
  • ✅ KV-backed rate limiting via Upstash Redis (30 req/min per IP, 120 req/min per key)
  • ✅ Self-serve key generation — enter email at /mcp, get instant key (5 per IP per day limit)
  • ✅ Keys expire after 90 days of inactivity
  • ✅ SHA-256 key hashing (never stored raw)

Option B: Self-hosted stdio (for local Cursor / Claude Desktop)

json
{  "mcpServers": {    "tokcalc": {      "command": "npx",      "args": ["-y", "@tokcalc/mcp-server"]    }  }}

No API key needed for stdio (local install). Cursor spawns the process via npx.

Option C: Self-hosted HTTP (for air-gapped / custom infra)

bash
npm install -g @tokcalc/mcp-servertokcalc-mcp-http  # defaults to port 3000

Set MCP_API_KEY, UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN env vars for auth + rate limiting.

Example agent prompt

"I need to serve Llama 3.3 70B at 32K context for 50 concurrent users. What GPU topology do you recommend, and how much will it cost per month?"

The agent calls list_models → list_gpus → recommend_topology → estimate_capacity → returns a structured plan with VRAM, throughput, latency, cost, and provenance.

Development & testing

bash
# Typecheck (must stay at zero errors)bunx tsc --noEmit
# Golden-number suite (33 tests) — hand-verified oracle valuesbun test tests/mcp-golden.test.ts
# Surface-parity suite (13 tests) — every surface advertises the same 11 toolsbun test tests/mcp-surface-parity.test.ts
# Catalog suite (29 tests) — schema conformance, id stability, provenance,# architecture-engine correctness, backward compatibilitybun test tests/catalog.test.ts
# Catalog validation (Zod schemas + id/provenance integrity) — CI gatebun scripts/catalog-validate.ts
# Build the npm server dist + prepublish guard (freshness + version sync)cd mini-services/mcp-server && bun run build && node scripts/prepublish-check.js
# 35-check black-box stdio QA battery against the freshly built distcd ../.. && node tests/qa-live-probe.mjs local# …or against the PUBLISHED npm tarball:node tests/qa-live-probe.mjs 0.3.4
# 20-check HTTP smoke probe against the hosted /api/mcp surfaceMCP_API_KEY=<key> EXPECTED_VERSION=0.3.4 node tests/http-smoke.mjs http://localhost:3001# …or against production:MCP_API_KEY=<key> node tests/http-smoke.mjs https://tokcalc.vercel.app

GitHub Actions runs all of the above (except the published-tarball mode) on every push — see .github/workflows/ci.yml.

Tech stack

  • Framework: Next.js 16 with App Router (Turbopack)
  • Language: TypeScript 5
  • Styling: Tailwind CSS 4 + shadcn/ui (New York)
  • Charts: Recharts
  • State: React hooks (useState + useEffect + useMemo)
  • Theme: next-themes (dark mode default)
  • MCP SDK: @modelcontextprotocol/sdk v1.30.1 (Streamable HTTP transport, stateless mode)
  • Auth: crypto.timingSafeEqual (constant-time bearer key validation)
  • Rate limiting: @upstash/ratelimit + @upstash/redis (sliding window, 30/min per IP, 120/min per key)
  • Analytics: Plausible (privacy-friendly, no cookies)
  • Error monitoring: Sentry
  • Database: None for core; Upstash Redis for API key storage + rate limiting

Project structure

tokcalc/├── src/│   ├── app/│   │   ├── api/│   │   │   ├── mcp/route.ts          # Public MCP endpoint (Streamable HTTP)│   │   │   ├── keys/route.ts         # Self-serve API key generation│   │   │   └── pricing/              # Live GPU pricing proxies│   │   │       ├── aws/route.ts│   │   │       ├── azure/route.ts│   │   │       ├── gcp/route.ts│   │   │       └── vast-ai/route.ts│   │   ├── compare/                  # SEO landing pages│   │   │   ├── h100-vs-h200/page.tsx│   │   │   └── gguf-q4-k-m-vs-q5-k-m/page.tsx│   │   ├── self-host-vs-openai-api/page.tsx│   │   ├── mcp/page.tsx              # MCP install docs + self-serve key form│   │   ├── page.tsx                  # Main calculator│   │   └── layout.tsx│   ├── lib/│   │   ├── mcp/│   │   │   ├── core.ts              # UNIFIED tool core — all 11 tools, both surfaces│   │   │   ├── server.ts            # thin shim → core (createMcpServer factory)│   │   │   ├── mcp-version.ts       # MCP_SERVER_VERSION — single source of truth│   │   │   ├── mcp-store.ts         # per-install store (spec cache + calibration)│   │   │   └── auth.ts               # validateApiKey (Redis + env var)│   │   ├── token-calc.ts             # Core calculation engine│   │   ├── mlperf-curated.ts         # 10 MLPerf v4.1 reference configs│   │   ├── price-schema.ts           # PriceRecord type + helpers│   │   ├── benchmark-schema.ts       # BenchmarkRecord + CalibrationResult│   │   ├── engine-presets.ts         # 5 engine presets (vLLM/SGLang/TRT-LLM/llama.cpp/generic)│   │   └── url-state.ts              # URL hash + localStorage persistence│   └── components/│       ├── benchmark-import.tsx      # Paste JSON → calibrate against estimate│       └── confidence-badge.tsx      # 🟢🟡⚪ confidence dots├── mini-services/│   └── mcp-server/                   # Standalone npm package (for stdio + self-hosted HTTP)│       ├── server.ts                 # thin shim → src/lib/mcp/core.ts (no duplicated handlers)│       ├── auth.ts                   # Bearer auth middleware (Node http)│       ├── rate-limit.ts             # Upstash rate limiter (Node http)│       ├── http.ts                   # Standalone HTTP entry (tokcalc-mcp-http)│       ├── index.ts                  # Stdio entry (tokcalc-mcp-server)│       └── package.json              # @tokcalc/mcp-server npm package├── public/│   ├── og.png                        # OG image│   └── manifest.json                 # PWA manifest├── src/app/sitemap.ts                # Generated sitemap (859 URLs — built from the catalog)├── server.json                       # MCP registry entry (packages + remotes)├── package.json                      # Web app deps└── next.config.ts

Acknowledgments

tokcalc builds on the work of:

  • vLLM team — PagedAttention, continuous batching (arxiv.org/abs/2309.06180)
  • llama.cpp / ggml-org — GGUF format and quantization variants
  • MLPerf / MLCommons — standardized inference benchmark methodology
  • Stanford HELM — efficiency-aware model evaluation framework
  • Anthropic / OpenAI / Google — published prompt-caching pricing rules
  • Model Context Protocol team — MCP Streamable HTTP transport spec (2025-03-26)
  • NVIDIA / AMD / Intel / Google / Groq / Cerebras — published hardware specs
  • Upstash — Redis + rate limiting infrastructure

Every formula has a citation. Every model/GPU/quant entry has a source URL where available. If you spot an unsourced claim, please open an issue.

Star history

[Star History Chart]


Live demo · MCP install docs · Public MCP endpoint · npm package · Contributing · License · Code of Conduct

Made with care by the tokcalc community. Apache 2.0 licensed.

来源:README.md,提交 f536eeb

工具

11

estimate_capacity

Estimate serving capacity

Estimate whether an LLM-serving configuration fits in memory and can meet throughput and latency targets. Returns VRAM/KV-cache breakdown, throughput and latency ranges, concurrency, cost, confidence, assumptions, and sources.

输入参数gpu必填model必填enginegpuCountbatchSizecacheHitRateoutputTokenspromptTokensquantizationcontextTokenskvQuantizationuseSpeculative另有 5 个

compare_gpus

Compare accelerators

Compare supported GPU or cloud SKU options for the same LLM workload. Use before recommending hardware.

输入参数gpuslimitmodel必填sortBygpuCountbatchSizeoutputTokenspromptTokensquantization

recommend_topology

Recommend GPU topology

Recommend feasible GPU/topology designs including tensor parallelism and context parallel (RingAttention) when needed.

输入参数model必填batchSizequantizationcontextTokens

estimate_api_vs_self_host

Compare API vs self-host

Compare monthly token-based API costs with self-hosted GPU infrastructure under stated utilization assumptions.

输入参数gpu必填model必填apiModelgpuCountinputTokensutilizationoutputTokensquantizationapiInputPriceapiOutputPricerequestsPerDay

list_models

List supported models

List tokcalc-supported model IDs and metadata. Use before estimating if the requested model is ambiguous or unknown.

输入参数isMoEfamilycategory

list_gpus

List supported accelerators

List GPU and cloud SKU IDs, memory, bandwidth, pricing, and categories.

输入参数vendorcategoryminVramGb

get_mlperf_benchmarks

Get MLPerf reference results

Retrieve curated MLPerf Inference v4.1 LLM benchmark reference configurations. Throughput is computed by tokcalc formulas (confidence_tier=derived). Use to cross-validate theoretical estimates against audited system configurations.

输入参数gpuModelscenarioworkload

find_config_for_slo

Find a config for an SLO

INVERSE planner: given model + context + traffic volume + optional TTFT/cost/throughput ceilings, search every GPU × topology (1/2/4/8 GPUs) and return feasible configurations ranked by cost, throughput, or value. Use when the user knows their SLOs but not the hardware.

输入参数model必填sortBybatchSizemaxTtftMsquantizationcontextTokensrequestsPerDaymaxCostPerMillionminTokensPerSecond

plan_deployment

Plan a deployment

One-call deployment decision brief for a specific config: memory breakdown with KV headroom, performance, rig cost, blended build-vs-buy with break-even, concrete risks (no-NVLink TP, tight headroom, long context), and next steps. Chains what would otherwise take 4 separate tool calls.

输入参数gpu必填model必填engineapiModelgpuCountbatchSizeoutputTokenspromptTokensquantizationapiInputPriceapiOutputPricerequestsPerDay另有 3 个

fetch_model_spec

Fetch upstream model spec

Fetch a model's real config.json from HuggingFace and diff it against tokcalc's catalog (layers, KV heads, head_dim, vocab, max context). Catches catalog drift before it corrupts KV-cache math. Cached 24h locally; use forceRefresh to re-fetch. Works offline via cache fallback.

输入参数hfRepomodelId必填forceRefresh

record_measured

Record a measured benchmark

Record a real-world measurement (observed tok/s, TTFT, ITL) for a model+GPU+quantization cell. Compares against the model's prediction, stores a measured/predicted ratio, and future estimate_capacity / find_config_for_slo results for that cell are annotated with your calibration. The estimator improves as you use it.

输入参数gpu必填model必填notesenginesourcegpuCountobserved必填batchSizeoutputTokenspromptTokensquantization

版本历史

7
  1. v0.3.4最新Oct 24, 2026
  2. v0.3.3Oct 3, 2026
  3. v0.3.0Sep 30, 2026
  4. v0.2.9Sep 30, 2026
  5. v0.2.0Sep 26, 2026
  6. v0.2.0-alpha.2Sep 25, 2026
  7. v0.1.3Sep 25, 2026

评分

已满足适用检查项的 90%

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

  • 近 30 天内可连通必需25 分
  • 已声明认证方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。