How I started counting tokens
I've been building a harness for my own work and keeping it token-optimized. It started in Claude Code, where I could see the token usage every time I called something. I got curious about what drove that number, kept asking questions, and traced part of it to tool definitions: the names, descriptions and input schemas a client loads so the model knows which tools exist.
Anything I find myself doing more than once goes into memory or CLAUDE.md first. Anything in memory that runs in context on every turn then gets turned into a skill or a script, because prose is probabilistic and code is deterministic.
That rule is why I used Notion's CLI. I wanted access to one thing. The Notion MCP server, in the client I use, arrives as 45 tools, each with a name, a description and a JSON input schema, and without deferred loading all 45 ride along on every request. Notion's official CLI, ntn, handles authentication and API requests from the terminal. The agent runs one command, reads one result, and only needs to know that command's syntax.
I'm moving my own pipelines from text into images, video and audio, where every call has a real price per image or per second of output. At that point the definitions an agent carries on every request start to show up on the bill.
How many tokens do MCP tool definitions use?
Tens of thousands. Anthropic's tool search docs put a five-server setup of GitHub, Slack, Sentry, Grafana and Splunk at "~55k tokens in definitions before Claude does any work." The same page names a second effect: "Claude's ability to pick the right tool degrades once you exceed 30–50 available tools."
Both get worse as the catalog grows. Anthropic's engineering team measured the other direction: when an agent loaded tool definitions on demand through code execution, one workflow went from 150,000 tokens to 2,000, a 98.7% reduction. That is the gap between a catalog that rides along on every request and one the agent pulls from only when a step needs it. Claude Code turns on tool search by default, so definitions load when the model searches for them, and its own cost guide makes the same call I did: CLI tools like gh, aws and gcloud "are still more context-efficient than MCP servers because they don't add any per-tool listing."
When does a CLI stop being enough for agent tool access?
A CLI stops being enough once more than one person needs the same tools. It authenticates with whatever token sits on the machine that runs it, which is what I want on my own laptop, since the machine, the token and the terminal history are all mine.
Put 50 people on Claude with tool access and the questions change:
- Who is allowed to call which tool?
- Which identity made each call?
- Where is the record of each call, and can security export it?
- How does someone turn one tool off for everyone at once?
Fifty laptops running a CLI leave those answers to each machine. The schema cost is gone, and fifty credentials now live wherever each person keeps them.
How does a gateway answer those questions?
By putting one endpoint in front of every tool server. The example I weighed is Cloudflare's MCP server portal, which "centralizes multiple Model Context Protocol (MCP) servers onto a single HTTP endpoint." Each of the four questions lands on a feature of it. People sign in through Cloudflare Access with the organization's identity provider, admins can "turn off individual tools or prompts," and Access logs each tool request, which Enterprise plans can push to a SIEM.
I went in expecting a governance feature and found the schema problem handled in the same place. The portal's context modes keep full definitions out of the model's context until it asks for them, though none is on unless the portal or the client asks for it. One mode lists tool names only, for up to 5x fewer tokens; another exposes two tools at a small constant cost; Code Mode lets the agent write code against the upstream tools, run in an isolated Worker where credentials stay outside the model context. Cloudflare has published its own number for Code Mode, measured on its own product: 52 tools whose definitions took about 9,400 tokens collapsed into 2 portal tools at roughly 600.
Should an AI agent use MCP, a CLI or a gateway?
A CLI for a narrow task one person runs, and a gateway as soon as more than one person needs the same tools. That's the rule I landed on, and the table is how I got there.
| Raw MCP | CLI | MCP through a gateway | |
|---|---|---|---|
| Definitions in context up front | Every tool, unless the client defers them | Close to none | Every tool by default; names only or a small constant once an optimization mode is on |
| Tool choice past 30–50 tools | Degrades, per Anthropic's docs | No catalog to choose from | Found by search once an optimization mode is on |
| Identity per call | Set by each server | The local machine's token | Sign-in through the organization's identity provider |
| Central record of each call | Set by each server | None | Yes |
| Turn a tool off for everyone | Per client | Per laptop | Once, at the gateway |
| Where it fits | A few tools, one person | One builder, one narrow task | A team |
What doesn't a gateway cover?
The portal docs name three limits: it takes remote HTTP servers only, so a local stdio server has to be hosted behind an HTTP endpoint first; some Access policies, such as independent MFA, aren't enforced during portal authorization; and some servers refuse proxy clients outright. The fourth limit is mine to solve: what a tool costs once it runs.
What I meter myself
A video render or an image generation still needs metering behind any gateway. In my own pipeline that is a per-account daily credit cap checked before any provider call, and an append-only audit table the worker can insert into but has no grant to update. A trace of the call arrives after the spend, so the cap has to refuse first, and the audit table means the worker can write history but cannot revise it.
Sources
All opened and checked on September 27, 2026, and the MCP server portals docs rechecked on October 25, 2026. Docs pages are live, and dated posts are listed newest first.
- Cloudflare docs: MCP server portals (context optimization, Code Mode policies, Logpush)
- Claude Code docs: Manage costs effectively
- Claude Code docs: MCP
- Anthropic docs: Tool search tool
- Notion CLI docs
- Cloudflare changelog: MCP server portals are generally available, September 24, 2026
- Cloudflare blog: Scaling MCP adoption, our enterprise reference architecture, April 14, 2026
- Anthropic Engineering: Code execution with MCP, November 4, 2025