tokenometer MCP server
2026년 10월 18일 커밋Claude, GPT-4o, Gemini 등 다양한 제공업체의 LLM 비용을 계산하고 토큰 수를 측정하며 지연 시간을 벤치마킹합니다.
다른 이름 faraa2m/tokenometer
- 스타
- 1
- Tools
- —
- 다운로드, 30일
- —
- 최신 버전
- —
- 마지막 커밋
- 2026년 10월 18일
- 라이선스
- MIT
tokenometer MCP란?
tokenometer은(는) MCP server입니다. Claude, GPT-4o, Gemini 등 다양한 제공업체의 LLM 비용을 계산하고 토큰 수를 측정하며 지연 시간을 벤치마킹합니다.
프로젝트 README에서 생성된 요약
tokenometer MCP server 정보
Tokenometer는 대규모 언어 모델을 사용하는 개발자가 다양한 프롬프트 형식에 따른 재정적 영향을 계산할 수 있도록 지원합니다. Claude, GPT-4o, Gemini, Mistral, Cohere를 포함한 여러 제공업체에 대해 프롬프트를 JSON, YAML, XML, Markdown 또는 일반 텍스트로 보낼 때 발생하는 비용을 비교할 수 있습니다. CLI 또는 VS Code 확장을 사용하여 현재 작업 중인 파일의 실시간 토큰 수와 USD 가격을 확인할 수 있습니다.
이 도구는 비용 추정과 지연 시간 벤치마킹을 결합하여 첫 번째 토큰 생성 시간(time to first token) 및 초당 토큰 수(tokens per second)와 같은 지표를 측정한다는 점에서 독보적입니다. 정확성을 보장하기 위해 Anthropic의 countTokens 또는 Google의 model.countTokens와 같은 실제 제공업체 API를 사용하는 실증 모드를 지원합니다. 또한 개발자는 GitHub Action을 통해 CI/CD 파이프라인에 통합하여 특정 USD 예산을 초과하는 pull request를 차단함으로써 프롬프트 엔지니어링 워크플로의 비용 가드레일로 활용할 수 있습니다.
활용 사례
- 1프롬프트 형식별 비용 비교특정 모델에서 JSON을 Markdown으로 전환했을 때 토큰 사용량과 총 비용이 줄어드는지 확인합니다.
- 2CI 환경에서 비용 회귀 방지프롬프트 파일의 변경으로 인해 총 비용이 설정된 예산을 초과할 경우 GitHub pull request를 자동으로 실패 처리합니다.
- 3실시간 비용 모니터링현재 프롬프트의 토큰 수와 예상 USD 비용을 에디터 상태 표시줄에서 직접 확인합니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
구성
ANTHROPIC_API_KEY
| 이름 | 설명 | 유형 |
|---|---|---|
| ANTHROPIC_API_KEY | — |
자동 검사
2026년 11월 15일에 실행됨전체 보고서 →아직 인증되지 않았습니다. 서버는 80점 이상의 점수, 심각한 결함 없음, 그리고 검사에 충분한 데이터를 갖추어야 합니다. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능faraa2m/tokenometer is public and reachablegithub.com/faraa2m/tokenometer ↗통과
- 패키지가 이 저장소를 소스로 명시검사되지 않음
- 빌드 출처(Sigstore 증명)검사되지 않음
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit or release 2026-10-18github.com/faraa2m/tokenometer ↗통과
- OpenSSF Scorecard검사되지 않음
- 패키지 이름이 인기 패키지와 유사하지 않음검사되지 않음
- 패키지 및 해당 종속성에 중요한 보안 권고 없음검사되지 않음
- 모델에 대한 숨겨진 지침 없음0 tool descriptions and the README read; no override phrases, credential paths or hidden characters통과
- 파괴적인 도구에 라벨 표시됨검사되지 않음
- 원격 엔드포인트가 MCP 핸드셰이크에 응답검사되지 않음
README
GitHub에서 보기Tokenometer
Tokenometer — LLM cost calculator, token counter, latency benchmark, and CI cost guardrail for Claude, GPT-4o, Gemini, Mistral, and Cohere. CLI + GitHub Action + VS Code extension + Claude Code skill. Live: https://tokenometer.dev
Created and maintained by Faraazuddin Mohammed · LinkedIn · HackerNoon
[!WARNING]
tokenometer.cloudis not affiliated with this project or its maintainer. Do not enter credentials, API keys, or provider tokens there. Official Tokenometer surfaces are this GitHub repository, the npm packages linked above, the VS Code/Open VSX marketplace listings, andhttps://tokenometer.dev.
Tokenometer answers a simple, expensive question: does it actually cost less to send your prompt as YAML, JSON, XML, or Markdown — across Claude, GPT-4o, Gemini, Mistral, and Cohere — and how fast does each provider actually respond? It started as a $23 question. Today it's the only LLM cost CLI that also tells you latency, ships a PR-blocking GitHub Action, lights up your editor's status bar, prices actual provider usage with priceUsage(), and teaches Claude Code agents to think in dollars.
Why Tokenometer vs alternatives
| Tokenometer | tokencost (AgentOps) | tiktoken (OpenAI) | gpt-tokenizer | promptfoo | gpt-token-counter-live (VS Code) | |
|---|---|---|---|---|---|---|
| Multi-provider (Anthropic / OpenAI / Google) | ✓ | ✓ | – | – | ✓ | – |
| Mistral support | ✓ | – | – | – | partial | – |
| Cohere support | ✓ | – | – | – | partial | – |
| Multi-format compare (JSON / YAML / XML / MD / text) | ✓ | – | – | – | – | – |
Empirical mode (real provider countTokens) |
✓ | – | – | – | partial | – |
| Latency (TTFT + tokens/sec, p50/p95) | ✓ | – | – | – | partial | – |
| Vision-token cost (image inputs) | ✓ | – | – | – | – | – |
| Cost (USD), not just tokens | ✓ | ✓ | – | – | partial | – |
| Honest "approximate" flag when offline is a proxy | ✓ | – | – | – | – | – |
| CLI | ✓ | ✓ | – | – | ✓ | – |
| GitHub Action (PR cost-diff guardrail) | ✓ | – | – | – | partial | – |
| Per-file attribution in CI | ✓ | – | – | – | – | – |
| SARIF output (GitHub code scanning) | ✓ | – | – | – | – | – |
| VS Code / Cursor extension | ✓ | – | – | – | – | ✓ |
| Claude Code skill | ✓ | – | – | – | – | – |
Tokenometer is the only tool in this list that combines multi-provider (5 providers, 63 models) + multi-format + empirical mode + latency benchmarking + USD cost + a PR-blocking GitHub Action + an editor extension + a Claude Code skill + an honest approximate-vs-exact flag. tokencost is the closest match for cost-in-USD across providers, but it doesn't compare formats, measure latency, or run as a CI guardrail. tiktoken and gpt-tokenizer are great single-provider primitives — Tokenometer uses gpt-tokenizer under the hood for the offline path. promptfoo is the broadest evaluator overall, but cost is one input among many; it isn't a dedicated cost-guardrail. The VS Code extension is real-time-in-editor only.
Findings (Anthropic, n=150 cells across 10 prompt shapes)
claude-opus-4-7realmessages.countTokensis +62% denser (median) than the popularcl100k_baseproxy. If you budget Claude cost fromtiktoken, you under-budget by ~half.claude-sonnet-4-6andclaude-haiku-4-5are within ~17% ofcl100k_base(and identical to each other — same tokenizer family).- Format choice (JSON / YAML / XML / Markdown / text) is a wash — within ~1pp on the median delta. Picking a cheaper model saves 7-12×; reformatting saves ~10%.
gpt-4oempirical (Anthropic's countTokens equivalent for OpenAI: tiktokeno200k_base) matches the offline tokenometer counts on 100/100 cells, exactly. Sanity anchor.
Reproduce: npm install && npm run benchmarks:empirical with ANTHROPIC_API_KEY set. Full sweep is free (countTokens is free).
Demo
$ tokenometer ./prompt.md --model claude-opus-4-7 --format json,yaml,markdown
Model Format Tokens USD Approx
────────────────── ────────── ──────── ───────── ──────
claude-opus-4-7 json 1,243 $0.0186 ✓
claude-opus-4-7 yaml 1,189 $0.0178 ✓
claude-opus-4-7 markdown 1,156 $0.0173 ✓
Cheapest: claude-opus-4-7 as markdown ($0.0173)
Priciest: claude-opus-4-7 as json ($0.0186, 1.08x more)
The Approx column shows ✓ when the count is a proxy (Anthropic / Google / Mistral-Tekken / Cohere offline) and is empty when it's an exact match (OpenAI offline, Mistral SentencePiece-family offline, or any provider with --empirical).
Real demo (with empirical mode + GIF) at https://tokenometer.dev.
Why this exists
Cost AND latency in one CLI — the only tool that does both. tiktoken and @anthropic-ai/tokenizer give you a token count for one provider. They don't tell you:
- What the same prompt costs across multiple providers and models (Claude, GPT-4o, Gemini, Mistral, Cohere)
- How fast each provider actually responds (TTFT + tokens/sec, p50/p95/mean) — a real generation, not a synthetic benchmark
- Whether format conversion (YAML ↔ JSON ↔ XML ↔ MD) actually moves the needle
- The empirical cost — what your provider actually charged on a real call, after prompt caching
- How to price actual provider-reported usage after a call completes, so routers and agent loops can keep a running task budget
- Whether a PR introduced a prompt-cost regression
- The vision-token cost when your prompt includes images
Tokenometer is dev-time, multi-provider, multi-format, optionally empirical, latency-aware, vision-aware, and CI-native. And the same core powers the CLI, the GitHub Action, the VS Code / Cursor status bar, and the Claude Code skill — counts, pricing, and tokenizer choices stay identical across surfaces.
Install
One-shot:
npx tokenometer ./prompt.md --model claude-opus-4-7
Global:
npm i -g tokenometer
tokenometer ./prompt.md --format yaml,json,xml,markdown,text --model claude-opus-4-7,gpt-4o,mistral-large-latest,command-r-plus-08-2024
Stdin works too:
echo "prompt body" | tokenometer - --model claude-sonnet-4-6
Run tokenometer --help for the full flag list and the current set of known model ids.
Adoption playbooks
Use docs/ADOPTION.md for copy-paste integration paths:
GitHub Actions cost gates, VS Code/Cursor rollout, MCP clients, LangChain,
Vercel AI SDK, OpenAI SDK, Anthropic SDK, and a PR cost-regression case study.
Canonical tutorial: Add an LLM Prompt Cost Gate to GitHub Actions in 10 Minutes.
Five-line use
1. Compare formats for a single prompt (offline, no API key)
tokenometer ./prompt.md --model claude-opus-4-7
Prints estimated tokens + USD across each format × the chosen model(s). Default model is claude-opus-4-7 (or auto-detected from *_API_KEY env vars); default formats are all of json,markdown,text,xml,yaml.
2. Empirical mode (real provider countTokens, with a hard ceiling)
ANTHROPIC_API_KEY=… tokenometer ./prompt.md --empirical --max-spend 0.05
For each (model × format) cell, calls the provider's exact token-count API:
- Anthropic →
messages.countTokens(free) - Google →
model.countTokens(free) - OpenAI → tiktoken
o200k_base(matches OpenAI's production count exactly, no API call) - Cohere →
POST /v1/tokenize(free, requiresCOHERE_API_KEY) - Mistral → unsupported (no public token-count endpoint); offline
mistral-tokenizer-jsis exact for SentencePiece-family models, approximate (chars/4) for Tekken-family models.
Set GOOGLE_API_KEY (or GEMINI_API_KEY) for Gemini, MISTRAL_API_KEY for Mistral, COHERE_API_KEY for Cohere. --offline forces the offline path even if --empirical is also passed.
3. CI guardrail (GitHub Action)
- uses: faraa2m/tokenometer/packages/action@v1
with:
paths: prompts/**/*.md,prompts/**/*.json
models: claude-opus-4-7,claude-sonnet-4-6,gpt-4o
formats: json,yaml,markdown
budget: '0.50' # USD; omit to disable the gate
top-n-files: 5 # rows shown in the per-file Δ table; the rest fold into <details>
Posts a sticky PR comment with the cost diff vs the base branch, including a per-file Δ table and a collapsible "all files" block. Fails the check when the total Δ exceeds budget. See packages/action/README.md for all inputs and outputs.
4. Live cost in your editor (VS Code / Cursor)
ext install faraa2m.tokenometer-vscode
Or install directly from the VS Code Marketplace or Open VSX (Cursor / VSCodium).
Status bar shows model · tokens · USD for the active prompt file, updates on every keystroke (debounced), and turns warning-colored when you exceed tokenometer.warnOnCostAbove. Same @tokenometer/core as the CLI — what you see in the editor matches what CI computes. See packages/vscode/README.md.
5. Claude Code skill (agentic prompt-cost awareness)
cp -R packages/claude-code-skill ~/.claude/skills/tokenometer
Installs the tokenometer-cost-check skill so Claude Code agents can answer "what does this prompt cost?" with a real number — they shell out to npx tokenometer instead of guessing from tiktoken. See packages/claude-code-skill/README.md.
Methodology
Tokenometer picks a tokenizer per provider and flags the count as approximate (approximate: true in the API result) when the offline path is a proxy:
| Provider | Offline tokenizer | Exactness | Empirical (--empirical) |
|---|---|---|---|
| OpenAI | gpt-tokenizer o200k_base |
exact | same o200k_base (matches OpenAI production count) |
| Anthropic | gpt-tokenizer cl100k_base |
approximate | messages.countTokens (exact, free) |
chars / 4 heuristic |
approximate | model.countTokens (exact, free) |
|
| Mistral | mistral-tokenizer-js (V1/V2/V3) · chars/4 for Tekken family |
exact for SP-family · approximate for Tekken | unsupported (no public token-count endpoint) |
| Cohere | chars / 4 heuristic |
approximate | POST /v1/tokenize (exact, free, requires COHERE_API_KEY) |
Cost = tokens / 1000 × per-1k input rate. Pricing and context windows are sourced from the tokenlens registry, with local overrides for current priced models the registry hasn't picked up yet. Visible provider models without public text pricing, stable access, or a supported token-counting path live in MODEL_CATALOG rather than KNOWN_MODELS — see packages/core/src/rates.ts (RATES_VERSION). Local overrides were last checked against OpenAI, Anthropic, Google, Mistral, and Cohere public docs on 2026-07-04.
Output formats
The CLI is multi-surface by design:
--output table(default) — human-readable per-cell table.--output json— emits aTokenometerResultshape ({ files: [{ path, results: [...] }] }); pipe tojq.--output sarif— emits SARIF 2.1.0; drop into GitHub Code Scanning or any SARIF viewer.--by-file— appends a per-file token + USD summary table for multi-file inputs.--image <path>(repeatable) — adds vision-token cost for Claude / GPT-4o / Gemini.--latency— measures real generation latency (TTFT + total ms + tokens/sec, p50/p95/mean overntrials, default 3). Implies--empirical. Supported on Anthropic, OpenAI, Google, Cohere, and Mistral.
npx tokenometer ./prompt.md --output sarif > tokenometer.sarif
npx tokenometer ./prompts/*.md --by-file --output json | jq '.files[].results | map(.inputCost) | add'
ANTHROPIC_API_KEY=… OPENAI_API_KEY=… npx tokenometer ./prompt.md --latency --model claude-opus-4-7,gpt-4o
Full flag reference: packages/cli/README.md.
Editor + Claude Code
- VS Code / Cursor —
@tokenometer/vscode. Status bar with live token count + USD cost; settings for model, format, and a warn-above-USD threshold;Tokenometer: Switch modelandTokenometer: Show detailscommands. - Claude Code skill —
@tokenometer/claude-code-skill. Drop in~/.claude/skills/tokenometer/SKILL.mdand Claude Code agents will reach fornpx tokenometer …when you ask them anything cost-shaped.
Project health
- Code of Conduct
- Contributing guide
- Security policy — uses GitHub Private Vulnerability Reporting
- Changelog
- Discussions
More from Faraazuddin Mohammed
Tokenometer is part of a focused open-source toolkit for LLM cost, tokenization, routing, and prompt optimization.
- llm-tokens-atlas — open benchmark of LLM tokenization calibration across providers.
- Hugging Face dataset — canonical public dataset behind the tokenization atlas.
- promptc — deterministic compiler for cost-aware prompt optimization.
- routerlab — cost-quality routing for LLM APIs with reproducible Pareto frontiers and budget-aware multi-step agent control.
- ast-ai-model-router — AST-aware Claude and Codex model router for token-conscious coding agents.
Status
v2.x — production-ready. Shipped across npm (tokenometer, @tokenometer/core, @tokenometer/mcp), VS Code Marketplace + Open VSX (faraa2m.tokenometer-vscode), the repo-hosted GitHub Action (faraa2m/tokenometer/packages/action@v1), and the live playground at tokenometer.dev. See CHANGELOG.md for release notes and the milestones page for what's next.
License
MIT
tokenometer MCP 질문
토큰 수가 항상 정확한가요?
항상 정확한 것은 아닙니다. 토큰 수가 근사치인지 제공업체로부터 받은 정확한 값인지 나타내는 'Approx' 플래그를 제공합니다.