MCP server or CLI for your coding agent? Prefer the CLI when one exists
If a mature CLI exists for the service, I point my coding agent at the CLI and skip the MCP server. The reason is context, but not the reason you've read before: tool definitions are no longer the main cost, because Claude Code and Codex both load them on demand. What a CLI saves now is result size, because the agent can pipe its output through jq or head before any of it reaches the context, and an MCP tool result arrives whole. Where no CLI exists, or the service is a hosted OAuth one, the MCP server is the better tool, and I run two of those myself.
What tool definitions cost now
An MCP server publishes a name, a description and a JSON schema for each tool. Agents used to send all of it with every request, which is where the well-known complaint comes from: Anthropic described a five-server setup of 58 tools using about 55,000 tokens before the conversation starts.
Claude Code no longer does that by default. Its MCP documentation says tool search keeps MCP context usage low by deferring tool definitions until Claude needs them: only tool names and server instructions load at session start. You can change that in three ways:
ENABLE_TOOL_SEARCH=falseloads every definition upfront.ENABLE_TOOL_SEARCH=auto:Ndefers only once the definitions pass N percent of the context window.alwaysLoad: trueon one server exempts that server from deferral.
Models earlier than Opus 4 and Sonnet 4 load everything upfront regardless, and so do Microsoft Foundry deployments hosted on Azure.
# Claude Code: defer MCP tool definitions only once they pass 5% of the context window
ENABLE_TOOL_SEARCH=auto:5 claude
# Claude Code: load every MCP tool definition upfront, as before tool search existed
ENABLE_TOOL_SEARCH=false claudeCodex doesn't document this. Its MCP page lists enabled_tools, disabled_tools and a per-tool output_token_limit, and says nothing about deferral. The source does: a removed feature flag in codex-rs/features/src/lib.rs is commented "MCP tools are always deferred when tool_search is available", and codex features list on version 0.167.0 shows tool_search_always_defer_mcp_tools as removed and true. I read that as deferral being the default, but I haven't traced a live session to confirm it, and the docs don't promise it.
Measured sizes
I counted tokens with the o200k_base encoding of tiktoken in a Python container. That is OpenAI's tokenizer, not the one Claude uses, so read the numbers as relative sizes. I had no API key for Anthropic's token-counting endpoint. For MCP servers I started each one in a container, sent a tools/list request over stdio, and counted the name, description and input schema of every tool. The CLI numbers come from the real --help output and real command output.
| What | Tokens |
|---|---|
| Official GitHub MCP server v2.1.0, 46 tools, all definitions | 11,132 |
| The same 46 tool names alone, roughly what loads upfront with tool search | 185 |
One loaded definition: list_issues / issue_write | 545 / 803 |
Reference server-filesystem, 14 tools | 1,693 |
Reference server-github (npm), 26 tools | 3,548 |
gh --help / gh issue list --help | 610 / 661 |
glab --help / glab issue list --help | 1,126 / 741 |
Two things stand out. A large server is expensive when loaded upfront (11,132 tokens before the first message), and cheap when deferred. And CLI help isn't free: glab issue list --help costs about as much as one MCP tool definition, and the agent pays it each time it needs a flag it doesn't remember.
Result size
A search or list call is where one agent session actually fills up. I listed 30 issues of gitlab-org/cli, a public project, with glab:
# 30 issues as the API returns them: 133,311 bytes, about 36,900 tokens
glab issue list --repo gitlab-org/cli --per-page 30 --output json
# the same 30 issues cut to the four fields the question needs: 8,903 bytes, about 2,400 tokens
glab issue list --repo gitlab-org/cli --per-page 30 --output json \
| jq --compact-output '[.[] | {iid, title, labels, updated_at}]'The unfiltered JSON is 36,922 tokens, and the filtered one is 2,420. The same experiment on 30 open issues of cli/cli through the GitHub REST API gave 66,756 tokens against 1,572. I used curl there because gh wasn't signed in here, so that pair stands for what gh api --jq or gh issue list --json produce, not for a run of gh itself.
This isn't a fair fight against every MCP server: a well-built one returns trimmed fields, and I didn't call the GitHub server to compare, because it needs a token. The structural difference holds anyway. A CLI result passes through a shell, so the agent chooses the fields and the row count in the same command. An MCP result goes straight into the context, and the client can only cap it afterwards. Claude Code warns when a tool result passes 10,000 tokens and limits it to 25,000 (MAX_MCP_OUTPUT_TOKENS), and Codex has tools.<tool>.output_token_limit. Both limits are a ceiling on the damage, not a way to ask for less.
The CLI doesn't do this for you either: the unfiltered glab call above costs 36,922 tokens, because the agent has to remember to add the jq. A TOOLING.md that names jq and the --output json flag helps with that.
When MCP is better
I'd reach for an MCP server in four cases:
- No CLI exists, or the one that exists doesn't cover what you need. Trello has an official remote MCP server, and I haven't found a CLI for it that I'd hand to an agent.
- The service is hosted and uses OAuth. Slack's MCP server sends each user through OAuth consent, and workspace admins can approve MCP client integrations. A CLI would mean a token you create, store and rotate yourself.
- The work needs state that outlives one command, such as a browser session with a page left open or a debugger attached. A CLI call starts and ends with its process.
- The agent has no shell. A sandboxed or hosted agent can call MCP tools but can't run
jq.
A tool schema also gives the client something a shell command doesn't: typed arguments, and an allow list per tool (enabled_tools in Codex) that decides what the agent may call before it runs.
My setup
This machine lists more than 40 tools in its TOOLING.md, among them gh, glab, kubectl, sentry-cli and gws, and agents use them directly. I run Slack and Trello through MCP, with one Slack server entry per workspace, because those two have no suitable CLI and both authenticate through a hosted OAuth flow.
With Claude Code, the claude role writes claude_code_mcps into its config, so the few servers that earn a place are declared in the same repository as the CLIs.
What this doesn't show
Five limits apply to these numbers:
- The counts use OpenAI's tokenizer, so the real Claude and Codex counts are different.
- I measured definitions and results separately and never ran a full agent session to compare total tokens per task.
- Tool search adds a search step before the first call to a deferred tool, which costs a round trip that I didn't time.
- The two issue lists show the raw API payload against a four-field one, so the gap depends on how many fields you ask for.
- The Codex behavior comes from its source and a feature list, not from its documentation.
Definitions are cheap now, and results are what fill the context. Prefer the tool that lets the agent shrink them before they arrive.