MCP vs CLI vs API Explained: What Your Agent Should Use
In 2025 the advice was to wrap everything in an MCP server. In 2026, engineers started to measure, and the CLI often won on tokens. Then the MCP spec changed, tool search arrived, and the argument turned again. The real answer is not one winner. Each of the three is the right tool for a different job. This guide gives the numbers, the rule, and where each one lives in OpenClaw.
Bottom Line
- All three can do the same job. “List my open pull requests” works with GitHub’s MCP server, with
gh pr list, or with one HTTP call. - The CLI is usually the cheapest when the model already knows the tool. One benchmark measured 32x fewer tokens than MCP on a task.
- MCP is the best fit when no good CLI exists, when you need OAuth per user, or when you want a short list of allowed actions.
- A direct API call is the best fit when you own the integration. Wrap it as one tool and keep the key out of the model’s sight.
- Tool search removes most of MCP’s token cost. Turn it on before you judge MCP by its token bill.
The Rule
| Use | When | Why |
|---|---|---|
| CLI | The model already knows it (gh, aws, git, kubectl) and the agent has a shell | Few tokens, output pipes through jq and grep, the auth already exists |
| MCP | No good CLI, a SaaS app, a team setup, or OAuth per user | Standard discovery, standard auth, a fixed list of actions |
| API | You own both sides and want an exact contract | Smallest surface, no extra process, full control of inputs |
The question of skills is a different split. A skill is a procedure, not an ability. Our MCP vs skills page covers it.
The Token Cost
Why MCP costs tokens before work starts
Most MCP clients load every tool definition into the context at the start. Anthropic’s November 2025 example had five servers:
| Server | Tools | Tokens |
|---|---|---|
| GitHub | 35 | About 26,000 |
| Slack | 11 | About 21,000 |
| Sentry | 5 | About 3,000 |
| Grafana | 5 | About 3,000 |
| Splunk | 2 | About 2,000 |
That is about 55,000 tokens of definitions, before the first message. Anthropic says it has seen tool definitions reach 134,000 tokens.
What the CLI benchmarks show
Scalekit (March 2026) ran Claude Sonnet 4 on 5 read-only GitHub tasks, 75 runs, with GitHub’s official MCP server (43 tools) against the gh CLI:
| Task | CLI tokens | MCP tokens | Ratio |
|---|---|---|---|
| Repo language and license | 1,365 | 44,026 | 32x |
| Latest release and dependencies | 8,750 | 37,402 | 4x |
The CLI also finished more often: 25 of 25 runs, against 18 of 25 for MCP. All 7 MCP failures were connection timeouts.
Read it with care. The sample is small, and Scalekit sells auth products. Its own conclusion is that MCP is still needed for multi-user auth.
Eric Holmes’s post “MCP is dead. Long live the CLI” (February 2026) gives the reasons. Models learned CLIs from years of man pages and scripts. CLI output pipes through other tools. And gh pr view can be allowed while gh pr merge asks first.
Tool search changes the math
The fix for MCP’s token cost is to load tool definitions only when the agent needs them. This is tool search. The agent sees a search tool, looks up what it needs, and only those definitions enter the context.
| Measure | Without tool search | With tool search |
|---|---|---|
| Context used before work (Anthropic example) | About 77,000 tokens | About 8,700 tokens |
| Opus 4 accuracy on Anthropic’s MCP evals | 49% | 74% |
| Opus 4.5 accuracy | 79.5% | 88.1% |
Anthropic’s docs say tool choice gets worse after 30 to 50 tools. More tools in the context make the agent pick worse, not only cost more.
Where tool search is today:
- Claude Code: on by default for MCP tools (
ENABLE_TOOL_SEARCH,autostarts at 10% of the context window). - Claude API:
defer_loading: trueon tools, up to 10,000 deferred tools. - OpenAI API: a
tool_searchtool withdefer_loading, ongpt-5.4and later. - OpenClaw:
tools.toolSearch, on by default for some run types. It is marked experimental.
One estimate on Hacker News put an 84-tool setup at about 15,540 tokens with plain MCP, about 500 with tool search and about 300 with a CLI. With tool search, most of the gap is gone.
What Changed in MCP in 2026
The MCP spec version 2026-07-28 is the biggest change since launch. Simon Willison wrote that it “recaptured” his interest.
| Change | What it means |
|---|---|
| No more sessions | The Mcp-Session-Id header is gone. Each request stands alone |
No initialize handshake | Each request carries its version and client abilities |
| Tasks moved to an extension | Long-running jobs use io.modelcontextprotocol/tasks, with polling and mid-job input |
| Fixed tool order | Servers should list tools in a fixed order, for better prompt cache hits |
| Sampling, Roots and Logging deprecated | Fewer features for clients to build |
Two more items people often attach to this release came at other times:
- MCP Apps (interactive UI in a sandboxed iframe) was already an extension, with a spec dated January 2026.
- The Skills extension for MCP went final on 13 September 2026, about six weeks later.
Stateless MCP is easier to run. A server is now closer to a normal web API behind a load balancer. That removes a common reason teams preferred a plain API.
Security: Who Holds the Keys
This is where the three differ most.
| CLI | MCP (remote) | API wrapped as a tool | |
|---|---|---|---|
| Where the credential is | Your shell login (gh auth, ~/.aws) | An OAuth token per server, refreshed by the client | Wherever the tool code reads it |
| What the agent can reach | Everything that shell login can reach | The actions the server exposes | The one action you wrote |
| Per-user auth | Hard. All users share one login | Built in (OAuth 2.1) | You build it |
| Easy to audit | Hard. Any command is possible | Easier. A fixed list of tools | Easiest |
Three facts from the sources:
- MCP auth is optional. A local stdio server reads credentials from its environment, like a CLI. The OAuth rules apply to remote HTTP servers.
- Remote MCP servers must not pass your token through to other services. The spec forbids it.
- A shell is a large surface. Willison’s view: MCP tools are easier to audit than a shell with network access.
A CLI gives the agent your full login. If the agent reads a poisoned web page, an injected gh repo delete is one command away. Our local LLM prompt injection guide covers this risk.
Where Each Lives in OpenClaw
| Path | OpenClaw feature | Settings and commands |
|---|---|---|
| MCP client | Connect OpenClaw to other MCP servers | mcp.servers.<name> with command/args (stdio) or url, transport, auth: "oauth". toolFilter.include/exclude limits the tools |
| MCP server | Expose OpenClaw to Claude Code and other clients | openclaw mcp serve |
| CLI | The exec tool | tools.exec.mode: deny, allowlist, ask, auto, full |
Managed gh login | A separate GitHub identity for the agent | tools.github |
| API as a tool | A plugin tool | api.registerTool in a plugin |
| Keys out of context | The secrets tool asks for a credential the agent never sees | On by default |
| Tool search | Load tool definitions on demand | tools.toolSearch |
A short example that adds a remote MCP server and keeps only the read tools:
openclaw mcp add docs --url https://mcp.example.com/mcp --transport streamable-http --include 'search,read_*'
openclaw mcp doctor docs --probe
Two warnings from the OpenClaw docs:
execis a mutating shell surface. Turning off thewriteandedittools does not makeexecread-only.- Exec approvals are not a per-user auth boundary. They decide which commands run. They do not limit which accounts those commands use.
A Decision Checklist
- Does the model already know a CLI for this? Use the CLI, with
tools.exec.mode: "allowlist"or"ask". - Will other people use this agent with their own accounts? Use MCP with OAuth.
- Is it your own service with 1 to 3 actions? Write one plugin tool that calls your API.
- Do you have more than about 10 MCP tools? Turn on tool search and filter the tools you do not need.
- Does the agent read untrusted content? Prefer the narrow option: MCP with a tool filter, or a plugin tool. Avoid a full shell.
Honest Caveats
- We did not run these benchmarks. The token numbers come from Anthropic, Scalekit and other public posts. The vendor posts sell related products.
- Token counts depend on the server. GitHub’s MCP server is large. A small server with 3 tools costs much less.
- Tool search in OpenClaw is experimental. Check
tools.toolSearchin your version. - MCP is still changing. Check the current spec before you build on a feature.
Sources
- MCP specification 2026-07-28 changelog and release post
- MCP authorization, 2026-07-28
- MCP Skills over MCP working group and MCP Apps
- Anthropic: Advanced tool use (November 2025): 58 tools, tool search accuracy
- Anthropic: Code execution with MCP (November 2025)
- Claude API: tool search tool and Claude Code MCP docs
- OpenAI: tool search
- Scalekit: MCP vs CLI benchmark (March 2026)
- Eric Holmes: MCP is dead. Long live the CLI and the HN thread
- Kan Yilmaz: CLI vs MCP token estimates
- Simon Willison: Stateless MCP has recaptured my interest (July 2026)
- Ask HN: Who is using MCP in production? (September 2026)
- OpenClaw docs: MCP config, MCP tools, mcp serve, exec, exec approvals, tool search, secrets
See Also
- Harness engineering explained: where tools fit in the full agent setup
- MCP vs skills for agent tools: ability vs procedure
- OpenClaw as an MCP server: what it exposes
- MCP server disconnects after console.log: the stdout trap
- OpenClaw security checklist: exec approvals and the sandbox