llm-pricebook-mcp
# llm-pricebook-mcp
An MCP server that lets AI assistants look up, filter, compare and estimate the cost of official LLM API prices, with the source page and verification date on every answer.
It covers 200+ models from Anthropic, OpenAI, Google, xAI, Mistral AI, DeepSeek, Alibaba Cloud (Qwen), Volcengine (Doubao), Zhipu AI (GLM), Moonshot AI (Kimi), MiniMax and StepFun, read from the open [LLM API Prices](https://github.com/LynShen-Team/llm-pricebook) dataset. It runs locally over stdio, needs no API key and only reads public data.
## Install and configure
Requires Node.js 20 or newer. Start it with:
```bash
npx -y llm-pricebook-mcp
```
### Claude Code
```bash
claude mcp add llm-pricebook -- npx -y llm-pricebook-mcp
```
To make it available in every project:
```bash
claude mcp add --scope user llm-pricebook -- npx -y llm-pricebook-mcp
```
### Claude Desktop
Settings → Developer → Edit Config, then add to `claude_desktop_config.json`:
```json
{
"mcpServers": {
"llm-pricebook": {
"command": "npx",
"args": ["-y", "llm-pricebook-mcp"]
}
}
}
```
Restart Claude Desktop.
### Cursor
Add to `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project):
```json
{
"mcpServers": {
"llm-pricebook": {
"command": "npx",
"args": ["-y", "llm-pricebook-mcp"]
}
}
}
```
### Other clients
Any MCP client that can launch a stdio server works: the command is `npx`, the arguments are `-y llm-pricebook-mcp`.
### Options
| Environment variable | Default | Meaning |
| --- | --- | --- |
| `LLM_PRICEBOOK_TTL` | `3600` | Seconds to reuse downloaded data before fetching again. |
| `LLM_PRICEBOOK_OFFLINE` | off | `1` = never use the network (same as the `--offline` flag). |
| `LLM_PRICEBOOK_CACHE_DIR` | `~/.cache/llm-pricebook-mcp` | Where the downloaded copy is kept between runs; `none` disables it. |
| `LLM_PRICEBOOK_URL` | the dataset's `v1/models.json` | Read a different copy, for example a mirror. |
## Tools
All tools are read-only. Prices are per 1M tokens in the provider's own currency (USD, CNY or EUR). When you ask for another currency, converted values are marked approximate and carry the exchange-rate date.
| Tool | What it does | Main arguments |
| --- | --- | --- |
| `get_model_price` | Every price row of one model: tiers, long-context bands, regions, cache prices, announced future prices, context window, capabilities. | `model` (id, alias, dated snapshot, display name or `provider/id`), `provider`, `tier`, `currency` |
| `find_models` | Search by capability, price, context window, provider or name; sort by price or size. | `requires` (`tools`, `vision`, `reasoning`, `prompt_caching`), `max_input_price`, `max_output_price`, `currency`, `min_context_window`, `sort_by`, `limit` |
| `compare_models` | 2–10 models side by side in one currency, optionally with the cost of a workload. | `models`, `currency`, `input_tokens`, `output_tokens`, `cached_input_tokens`, `tier` |
| `estimate_cost` | Cost of a workload on one model. Picks the long-context band from the per-request token counts and supports batch, flex, priority and fast tiers, cache hits and cache writes. | `model`, `input_tokens`, `output_tokens`, `cached_input_tokens`, `cache_write_tokens`, `requests`, `tier`, `mode`, `time`, `region`, `currency` |
| `list_providers` | Providers, model counts, official pricing pages and the exchange rates used for conversion. | `region` (`intl` or `cn`) |
Every result includes:
- `source`: the official pricing page each price comes from, and `verified`: the date it was last checked;
- `data`: where the data came from (`live`, `disk-cache` or `bundled-snapshot`), when the dataset was generated, and a `warning` if it is not fresh.
### Example conversations
> **You:** Which models support vision and tool calling, cost under $1 per million input tokens, sorted by output price?
>
> **Assistant** *(calls `find_models` with `requires: ["vision","tools"]`, `max_input_price: 1`, `sort_by: "output_price"`)*: 31 models match. The cheapest on output are Ministral 3B ($0.10 in / $0.10 out), Ministral 8B ($0.15 / $0.15) and Ministral 14B ($0.20 / $0.20). Doubao Seed 2.0 Mini is priced in CNY: ¥0.2 / ¥2, about $0.03 / $0.30 at the 2026-11-27 rate…
> **You:** We send 1,000 requests a day to claude-haiku-5-5, each with 150K prompt tokens of which 100K hit the cache, and 4K output tokens. What does that cost?
>
> **Assistant** *(calls `estimate_cost`)*: About **$40 a day**. Because each prompt is over 100K tokens, the long-context price applies: 50M uncached input × $0.50 = $25, 100M cached × $0.05 = $5, 4M output × $2.50 = $10. Source: Anthropic's pricing page, verified 2026-11-30.
> **You:** Compare gpt-5.5, claude-haiku-5-5 and deepseek-flash.
>
> **Assistant** *(calls `compare_models`)*: In USD per 1M tokens: GPT-5.5 $5 / $30, Claude Haiku 5.5 $0.10 / $0.50, DeepSeek Flash ≈$0.30 / ≈$1.20 (converted from ¥2 / ¥8, peak-hour price; off-peak is half)…
> **You:** How much is `claude-sonnet-4-5`?
>
> **Assistant** *(calls `get_model_price`; the alias resolves to `claude-sonnet-4-5-20250929`)*: $3 input / $15 output, cache reads $0.30, 5-minute cache writes $3.75, 1-hour cache writes $6; batch is half price. The model is marked deprecated.
The numbers above are illustrative; the assistant always answers from the current data.
## Data source and conventions
- **Source.** Prices come from the [LLM API Prices](https://github.com/LynShen-Team/llm-pricebook) dataset, which records each provider's official API price page and is rebuilt daily. The server reads `https://lynshen-team.github.io/llm-pricebook/v1/models.json`.
- **Freshness.** The file is fetched on first use and reused for an hour (kept on disk between runs). If the network is unavailable, the server uses its last downloaded copy, and failing that the snapshot bundled in the package. Answers then say so and give the data date.
- **Versions.** The server reads the dataset's `version` field and only interprets versions it understands. The `v1` URL is kept stable; additive changes are picked up automatically, and if an unknown version appears the server falls back to its cached copy or snapshot and asks you to update the package.
- **Main price.** `prices[0]` of a model is its main price: standard tier, default region, lowest context band. `find_models` and `compare_models` use it; `get_model_price` shows every row.
- **Original currency.** Chinese providers usually price in CNY, others in USD; some list both (for example a China region in CNY and an international region in USD). Nothing is converted unless you ask. Conversions use the dataset's exchange rate (ECB reference rates) and are approximate.
- **Bands and variants.** Long-context bands are chosen from the tokens of a single request (`input_tokens`, `output_tokens` per request, not totals). When the same request has several prices, for example thinking vs non-thinking mode or peak vs off-peak hours, `estimate_cost` returns each variant and a range unless you pass `mode` or `time`.
- **Missing prices are never zero.** If a price is not listed, the total is reported as unknown, or, for a missing cache-read price, cached tokens are charged at the input price and the result says it is an upper bound.
- **Not included.** Subscription plans, free tiers and rate limits, image/audio/video pricing, taxes, and negotiated or reseller prices.
## FAQ
**Does it need an API key or send my prompts anywhere?**
No. It downloads one public JSON file and answers from it. Nothing about your conversation is sent.
**How current are the prices?**
The dataset is rebuilt every day and each model shows the date its price was last verified. The `data.generated_at` field in every answer tells you how old the copy in use is.
**Can I use it offline or behind a firewall?**
Yes. Start it with `--offline` (or `LLM_PRICEBOOK_OFFLINE=1`) to use the bundled snapshot, or point `LLM_PRICEBOOK_URL` at an internal mirror. If you need an HTTP proxy, Node.js 24 and later honour `HTTPS_PROXY` when `NODE_USE_ENV_PROXY=1` is set.
**A model is missing or a price is wrong.**
Please open an issue or pull request on the [dataset repository](https://github.com/LynShen-Team/llm-pricebook) with a link to the official pricing page. This server picks up the fix within an hour of the dataset being rebuilt.
**My client says the model name is ambiguous or unknown.**
Pass `provider` as well, or use the full `provider/id` key. Unknown names return the closest suggestions.
**Why is a converted price marked "approx"?**
Providers bill in their own currency. Converted figures use a daily reference rate and will differ slightly from what your bank or the provider charges.
## Development
```bash
npm ci
npm run build
npm test # unit tests (vitest)
npm run smoke # starts the built server and calls every tool against the live dataset
npm run update-snapshot
```
Code: [MIT](LICENSE). Bundled data: [CC BY 4.0](data/README.md).
Made by LynShen-Team
TDQS
Scored across 5 tools
Each tool has a distinct role: single-model detail lookup (get_model_price), discovery/filtering (find_models), multi-model comparison (compare_models), workload cost math (estimate_cost), and provider listing (list_providers). The boundary between get_model_price and compare_models is slightly soft since a 1-model 'comparison' could substitute for a price lookup, but the descriptions make the intended split clear.
All five tools follow a clean verb_noun snake_case pattern: get_model_price, find_models, compare_models, estimate_cost, list_providers. No mixed conventions or vague verbs.
Five tools is well within the sweet spot and each maps to a distinct step in the pricing workflow (lookup, search, compare, estimate, browse providers). Nothing feels redundant or padded.
The surface covers discovery, detail, comparison, and cost estimation over official prices plus provider metadata, which is a solid read-only lifecycle for a pricebook. Minor gaps exist, such as a dedicated way to browse price history or enumerate currencies/tiers independently, but agents can work around these via find_models and get_model_price.