# Token budget

`budget` is what `initialize` and `tools/list` cost in Claude tokens before any call. A client sends the model the tools' `total` plus the server's `instructions` before the first call.

```text
budget: 553 Claude tokens for the tools list at 2.4 characters a token, plus 1621 for the instructions
  tool                 description  input  output  total
  ask_wiki_question             45    148      46    244
  read_wiki_structure           25     82      46    158
  read_wiki_contents            19     82      46    151
  output schemas: 138 tokens, outside the total; whether clients send them to the model is unverified
```

## What it counts

Each tool has a row: its description, its input schema, its output schema, and `total`, the whole tool entry without its output schema. The server's instructions get their own row, `instructions`, outside the tools' `total`. Output schemas are counted apart in `outputSchemas`, since whether clients send them to the model is unverified.

Tokens are characters divided by 2.4, the `ratio` in the report. The usual ÷ 4 fits OpenAI's tokenizer, which measures 4.0 to 4.6 characters per token on `tools/list`. Claude measures 2.4 to 2.9 on `tools/list`, so ÷ 4 undercounts it by a quarter to a half.

## Set a limit

Install the [preview CLI](https://ismcpok.dev/docs/guide/installation#try-the-preview-cli) for the examples below. npm `0.1.1` reports the budget but doesn't have the flags to save a baseline, compute a diff or enforce a limit.

Two flags fail a run on the budget, as a bundle-size check does:

- `--max-tokens <n>` exits `1` when it is over `<n>` Claude tokens.
- `--max-increase <n|n%>` exits `1` when it grew by more than `<n>` tokens, or `<n>` percent, since a baseline.

A baseline is the last `tools/list` you accepted, saved as JSON. `--save` writes what the CLI read from a server, `{ initialize, tools }`, never the calls, a header or the URL:

```sh
pnpm exec is-mcp-ok http://localhost:3000/mcp --save mcp-tools.json
pnpm exec is-mcp-ok http://localhost:3000/mcp --baseline mcp-tools.json --max-increase 5%
```

Commit the baseline, and a pull request's diff shows which descriptions and schemas changed. To accept a larger budget, run `--save` again and commit the file. Any file the CLI reads works as a baseline.

## The diff

With `--baseline`, the text output adds each tool that was added, removed or changed cost:

```text
budget vs mcp-tools.json: 1930 → 2174, +244 Claude tokens (+12.6%)
                           before  after  change
  ask_wiki_question (new)       –    244    +244
  2 tools unchanged
```

`--json` adds `budgetDiff`: `before`, `after`, `delta` and `share`, the `instructions` before and after, and the same tool changes. Both sides are measured with the CLI that runs, so a new ratio never shows as a change.

Tool rows are rounded one by one, while the total is rounded after adding up characters. An edit can leave every row the same and still move the total.

## List advice

`advice` holds rules on the list that cost tokens or calls without failing anything: no server instructions, a description that never says when to use the tool, output keys in mixed styles, or one parameter spelled two ways across tools. [List advice](https://ismcpok.dev/docs/reference/mcp#list-advice) has each rule and its fix. Advice is `info` and never changes the exit code.

<!-- vitehub-docs:section-links -->
## In this section

- [Introduction](https://ismcpok.dev/raw/docs/guide.md)
- [Installation](https://ismcpok.dev/raw/docs/guide/installation.md)
- [Check a server](https://ismcpok.dev/raw/docs/guide/servers.md)
- [Check answers](https://ismcpok.dev/raw/docs/guide/answers.md)
- [Token budget](https://ismcpok.dev/raw/docs/guide/budget.md) (this page)
- [Run in CI](https://ismcpok.dev/raw/docs/guide/ci.md)
- [Check tools in your tests](https://ismcpok.dev/raw/docs/guide/testing.md)
- [Coding agents](https://ismcpok.dev/raw/docs/guide/agents.md)

Next: [Run in CI](https://ismcpok.dev/raw/docs/guide/ci.md)

All pages: [llms.txt](https://ismcpok.dev/llms.txt)
