# MCPCost

> A public board that probes every server in the official MCP registry and counts, exactly, what its tool definitions cost in Claude. 30 000 servers, a CLI and a GitHub Action for your own config, a JSON API and an MCP server.

- **Role:** Author & Maintainer
- **Year:** 2026
- **Tech:** TypeScript, Astro, Cloudflare Workers, D1, MCP, Anthropic API, GitHub Actions, Docker
- **Repository:** https://github.com/ondraulehla/mcpcost
- **Live:** https://mcpcost.ulehla.dev
- **Canonical page:** https://ulehla.dev/projects/mcpcost

**Problem.** An MCP server hands your agent its tool definitions at the start of every session and you pay for them in every turn. Nothing tells you what a server costs before you add it, or whether it still answers at all.

**Solution.** A daily probe connects to every server in the registry the way a client does, lists its tools and asks the Anthropic count_tokens endpoint for the exact cost. Remote servers daily, npm and PyPI packages in containers. The board ranks servers by it; npx mcpcost does the same for your own config.

**Outcome.** Live at mcpcost.ulehla.dev: 16 586 of 30 024 servers answer, the median tool set costs 2 737 tokens in Claude Opus 5.5 and the heaviest 944 524. The o200k estimate everybody used undercounts by 1.8×.

---

## Context

Every MCP server you connect sends the model the name, the description and the
input schema of each tool. The client does this at the start of a session and
again in every turn. These definitions are part of the prompt. You pay for them
when the model calls no tool at all. The official registry lists 43 000 servers
and says nothing about this cost, or about whether a server is still up.

## What it does

A GitHub Actions job connects to every remote server in the registry once a
day with the official TypeScript SDK: `initialize`, then `tools/list`, no
credentials. Servers that ship as npm or PyPI packages run in containers with
the network off, one seventh of them each day. The probe records the result,
the protocol version, the latency and the tools. Then it asks the Anthropic
`count_tokens` endpoint what the tools cost: one request with the tools plus a
marker tool, one with the marker only. The difference is the exact cost in
Claude Opus 5.5. A second count adds the `mcp__server__` prefix that Claude
Code puts on every tool name. The endpoint is free and calls no model.

The board at [mcpcost.ulehla.dev](https://mcpcost.ulehla.dev) has a page per
server with the answer in the first sentence, a searchable list, charts, a live
check for any URL, a daily diff with Atom feeds, a JSON API and its own MCP
server with four tools. `llms.txt` and JSON-LD make the pages readable for
agents and search engines.

```bash
npx mcpcost                 # what the servers in your own config cost
npx mcpcost --claude        # exact counts, needs ANTHROPIC_API_KEY
npx mcpcost --budget 30000  # fail CI when a config grows past the budget
npx mcpcost mcp             # the same measurements as an MCP server
```

The GitHub Action `ondraulehla/mcpcost@v1` runs the budget check in a pull
request and writes a table of servers and costs to the job summary.

## Engineering notes

- **Exact, not estimated.** The first version counted with the `o200k_base`
  tokenizer. Calibration against `count_tokens` showed Claude charges 1.5 to
  3.8 times more, so the board switched to the exact number and keeps the
  estimate next to it.
- **Free tier all the way.** Cloudflare Workers and D1 serve the site. D1 counts
  every index entry as a row written, so the importer diffs against the previous
  run, updates only the columns that changed and refuses a run that looks like a
  mass outage. A broken runner once marked half the registry down; the guard
  came the same evening.
- **Crawlers pay for page views.** Thousands of sort and filter variants of the
  list, each read with OFFSET, spent the daily read budget in one afternoon.
  Cursor paging, `noindex` on list variants and `robots.txt` cut reads by 94 %.
- **No JavaScript on the board.** Inline CSS, server rendering, edge cache keyed
  by deploy version. The live check is the one page with a script.
- **A good guest.** One probe per host at a time, three requests per server, a
  User-Agent that links to the repository, and an issue template to opt out.
- **Renamed once.** It started as mcp-pulse with a CLI called mcptop. Both names
  collided with existing projects, so everything became MCPCost while the
  change was still cheap.
