MCP vs CLI: Why MCP Servers Drain Your Context Window A developer measured the context-window cost of MCP tool definitions by starting five MCP servers over stdio and counting tokens in each tool's name, description and inputSchema with OpenAI's tiktoken o200k_base encoding. Four common servers (Playwright, filesystem, memory and everything) exposed 66 tools that consumed 11,923 tokens of definitions before any work began, while a three-tool Apidog MCP server cost 291 tokens and an Apidog CLI skill added just 112, since a CLI is only paid for when the agent invokes it. The developer notes Anthropic's documentation warns multi-server setups can consume roughly 55k tokens in definitions and that Claude's tool-selection accuracy degrades past 30 to 50 tools. MCP vs CLI comes down to when your agent pays for a tool. An MCP server sends every tool's name, description and JSON Schema to the model before you type anything. A CLI costs nothing until the agent runs it and reads its --help or output. On a measured setup, four common MCP servers added 11,923 tokens of tool definitions; the Apidog CLI skill added 112. That gap is the whole story behind two Dev.to http://Dev.to posts this week. One developer typed "Run tests" into a coding agent and saw 28,400 input tokens on the first request https://dev.to/necoz/your-mcp-servers-are-silently-draining-your-context-window-the-hidden-cost-of-tool-heavy-ai-agents-fkl , with no files attached and no history. The culprit was seven MCP servers. Another argued that MCP is dead simple to build https://dev.to/sylwia-lask/mcp-is-dead-simple-and-thats-exactly-the-problem-5811 , and that the hard parts auth, approvals, duplicate calls start right after the demo works. This article stays on one question: what do tool definitions cost your context window, and when does a CLI the agent calls on demand cost less? If your problem is huge tool responses instead, read the companion piece on trimming bloated API responses http://apidog.com/blog/agent-tool-response-context-window?utm source=dev.to&utm medium=wanda&utm content=n8n-post-automation . An MCP server advertises its tools through the tools/list method. Per the MCP tools specification https://modelcontextprotocol.io/specification/latest/server/tools , each tool carries a name , a description and an inputSchema a JSON Schema for its arguments . For the model to pick a tool, the client has to put those definitions into the request. In a classic setup, that happens on every turn of every conversation, whether the agent calls the tool or not. So the cost grows with three things: The necoz post puts numbers on it: a 52-tool stack cost 24,600 tokens of schema on turn 1, against 640 tokens for a 4-tool setup, and about 246,000 tokens across a 10-step loop. Treat those as one developer's measurement, not a benchmark. Prompt caching cuts the dollar cost of repeated definitions, but the tokens still occupy the window and compete with your code for attention. There's a quality cost too. Anthropic's tool search documentation https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool says a multi-server setup with GitHub, Slack, Sentry, Grafana and Splunk "can consume ~55k tokens in definitions before Claude does any work", and that Claude's tool selection accuracy degrades once you pass 30 to 50 available tools. On 2026-11-16 I started five MCP servers locally over stdio, sent initialize and tools/list from a 30-line Node script, and counted the tokens in each tool's name , description and inputSchema . One caveat up front: I counted with OpenAI's tiktoken https://github.com/openai/tiktoken o200k base encoding because it runs offline. Claude, Gemini and other models use their own tokenizers, so your counts will differ by some margin. The ratios between setups are what matter here. | MCP server version | Tools | Definition tokens | Avg per tool | |---|---|---|---| | @playwright/mcp 0.0.85 | 25 | 4,634 | 185 | | @modelcontextprotocol/server-filesystem 2.3.0 | 16 | 3,281 | 205 | | @modelcontextprotocol/server-memory 2.1.1 | 9 | 2,013 | 224 | | @modelcontextprotocol/server-everything 2.3.0 | 16 | 1,995 | 125 | | Those four together | 66 | 11,923 | 181 | | apidog-mcp-server 0.0.18 | 3 | 291 | 97 | Four ordinary servers cost about 12,000 tokens before the agent reads a file. The last row is the useful counterexample. The Apidog MCP server exposes three narrow tools read the project's OpenAPI spec, read $ref files, refresh the spec , so it costs 291 tokens. Tool count and schema depth drive the bill, not the protocol. For the CLI side, I measured what an agent actually reads when it uses Apidog CLI 2.2.12: | CLI text | When it enters context | Tokens | |---|---|---| | Apidog CLI skill description frontmatter | Every session, as a skill listing | 112 | | Apidog CLI skill body | Only when the task matches | 1,189 | | apidog --help | Only when the agent runs it | 668 | | apidog test-case --help | Only when the agent runs it | 511 | | apidog run --help | Only when the agent runs it | 1,036 | The always-on cost of the CLI route is 112 tokens. Even if the agent loads the full skill and reads three help pages, it lands near 3,500 tokens, and only in the conversation that needs it. | | MCP server definitions loaded upfront | CLI called through the shell | |---|---|---| | Upfront cost | Every tool's schema, every turn | Zero, or a short skill description | | Discovery | Structured tools/list | --help text, read when needed | | Output | Whatever the tool returns | Whatever the command prints you can filter it | | Works across clients | Any MCP client, one config | Any agent with a shell tool | | Typed arguments | Yes, via JSON Schema | Flags; payload files validated separately | | Auth and permissions | Server's job OAuth for remote HTTP servers | Your local login and shell permissions | The CLI wins on upfront cost because the agent already has a shell tool. Running apidog endpoint list --project 123 uses the Bash tool it was going to load anyway. The MCP route wins when you need the same capability in several clients without writing an integration for each, which is the point Sylwia Lask makes: MCP isn't a replacement for REST, it's a standard way for AI clients to discover and call tools. Before you rip out every server, check what your agent does. The cost above assumes definitions load upfront. Some clients no longer do that by default. Claude Code's MCP documentation https://code.claude.com/docs/en/mcp says tool search is enabled by default: "Only tool names and server instructions load at session start", and full definitions load when Claude searches for them. You control it with ENABLE TOOL SEARCH : true : MCP tools are deferred and loaded on demand auto : tools load upfront while their definitions total under 10% of the context window auto:N : the same, with your own percentage false : every MCP tool loads upfront Two exceptions matter. Models earlier than Opus 4 and Sonnet 4 load MCP tools upfront regardless, and a server set to alwaysLoad: true skips deferral. Run /context in Claude Code to see which tools are marked deferred. On the Claude API itself, the same idea is the tool search tool: you set defer loading: true on tools that shouldn't load upfront, and Anthropic says it typically cuts definition tokens by over 85%. Deferral fixes definition cost, not output cost: Claude Code warns when an MCP tool returns more than 10,000 tokens and caps output at 25,000 by default MAX MCP OUTPUT TOKENS . New to the protocol? Start with what MCP is and why it matters for APIs http://apidog.com/blog/what-is-mcp-model-context-protocol?utm source=dev.to&utm medium=wanda&utm content=n8n-post-automation . For API design, testing and docs, use this split: jq or --reporters to keep it short. Whichever you pick, Sylwia's warnings still apply: a tool that writes data needs server-side permission checks, a human approval step for risky actions, and duplicate detection so a rerun doesn't create the same record twice. Here's the CLI route for API work, with your coding agent doing the typing. Install the CLI, log in once and add the agent skill: npm install -g apidog-cli@latest apidog auth login --with-token