Skip to main content
Glama
TokensWatch MCP server

TokensWatch MCP server

by CoryMink
README.md
# TokensWatch MCP server

<img src="https://tokenswatch.net/icon-512.png" alt="TokensWatch" width="64" align="right">

A free, remote [MCP](https://modelcontextprotocol.io/) server that gives AI assistants current
**LLM API prices**: standard input/output plus prompt-cache, Batch API, long-context and off-peak
rates for models from Anthropic, OpenAI, Google, xAI, DeepSeek and Mistral. Prices are re-verified
twice a day against each provider's own pricing page.

- **Endpoint:** `https://mcp.tokenswatch.net/mcp` (Streamable HTTP, no auth, read-only)
- **Docs:** https://tokenswatch.net/mcp/
- **Registry:** `net.tokenswatch/mcp` in the official MCP Registry
- **Data:** the same open dataset as https://tokenswatch.net/data/ (CC BY 4.0)

## Connect

Claude Code:

```sh
claude mcp add --transport http tokenswatch https://mcp.tokenswatch.net/mcp
```

Cursor, VS Code and other `mcp.json` clients:

```json
{ "mcpServers": { "tokenswatch": { "url": "https://mcp.tokenswatch.net/mcp" } } }
```

Claude.ai / ChatGPT: Settings → Connectors → add a custom connector with the endpoint URL.

## Tools

| Tool | What it does |
| --- | --- |
| `list_models` | Prices for every model; filter by provider, tier or context window, sort by price |
| `get_model_pricing` | Full pricing for one model: cache, batch, long-context, off-peak, limits, upcoming changes |
| `estimate_cost` | Cost per request, day and 30-day month; compare named models or rank the cheapest |
| `price_changes` | Dated history of price changes, filtered by model or date |

Example questions: *"Cheapest model with a 1M-token context window?"*, *"Compare Claude Sonnet 5.5
and GPT-6.2 Sol for 3,000 input and 800 output tokens, 20,000 requests a day."*

Cost estimates leave out cache-write charges, tool/search fees and image or audio tokens.

## How it works

A stateless Cloudflare Worker using the official MCP TypeScript SDK
(`WebStandardStreamableHTTPServerTransport`, JSON responses):

- `src/index.js`: request handling, CORS, per-IP rate limit, a fresh server per request.
- `src/tools.js`: tool schemas (zod) and handlers.
- `src/pricing.js`: pure cost logic (unit-tested).
- `src/data.js`: loads `https://tokenswatch.net/data/v1/*.json`, memoised for 5 minutes.

## Develop

```sh
npm install
npm test                                   # unit tests
npm run dev                                # local server on :8787
node test/e2e.mjs http://127.0.0.1:8787    # end-to-end MCP check
```

`wrangler.jsonc` contains the production bindings (service binding to the site Worker, custom
domain); remove those to deploy your own copy.

## Licence

Code: MIT. Pricing data: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), credit
[TokensWatch](https://tokenswatch.net).