Blog / How to optimise your MCP tools by knowing how agents call them

MCP server or CLI for AI agents? We ran the same jobs through both

Everyone has an opinion on MCP versus CLI, and most of it is about tokens. Before you build one or the other, you want to know if agents get the job done better with either. So we built one tool core, served it both ways, and ran the same five questions in Claude Code and Codex.

Leonid Bugaev · Published 21 Oct 2026

The setup

We wanted a fair fight, so both interfaces share one core: a mock task tracker, “Acme Tasks”, with synthetic data (4 projects, 6 people, 36 tasks, 76 activity events) and 21 tools. The MCP server exposes them as tools. The CLI exposes the same 21 as commands, with the same descriptions as help text and the same JSON output. Write commands exist in both but change nothing.

Same data + 21 tools→MCP server/CLI: acme <command>→Claude Code, Codex→Answer vs known truth

Five questions, in users' words, each with one right answer:

Each ran twice per setup: 2 apps × 2 interfaces × 5 jobs × 2 runs = 40 runs. In MCP mode the app could use only the server; in CLI mode only a shell restricted to the acme command.

Results

Same jobs, two interfaces, two apps (mock, 21 Oct 2026)
SetupPassedMedian input tokensRangeRuns with argument errors
Claude Code + MCP10/10 (72–100%)19,83713,751–25,6650/10
Claude Code + CLI10/10 (72–100%)25,70016,371–42,7203/10
Codex + MCP10/10 (72–100%)78,39057,821–100,4820/10
Codex + CLI10/10 (72–100%)72,78154,328–76,4370/10
Claude Code + MCP
19,837
Claude Code + CLI
25,700
Codex + MCP
78,390
Codex + CLI
72,781

With 10 of 10 everywhere, the ranges overlap completely: there is no evidence that either interface gets the job done more often. Ten runs per setup can't rule out a small difference, but it does rule out the big one people argue about. The median number of server calls was 2 in every setup (2.5 for Claude Code's CLI runs), and median time was within 2 seconds.

Find out whether your CLI or MCP server works for agents.

We run your users' real jobs through Claude Code, Codex and the other apps they use, against your MCP server, your CLI or both, and report pass rates, tokens and failures with confidence ranges.

Test your CLI or MCP

Why the token difference flips

Through MCP, the app gives the model tool definitions. Through a CLI, the model reads help text instead, as command output, and needs a few extra turns to do it. Which costs more depends on how the app handles each:

Treat both token gaps as small: the ranges overlap in both apps. Codex's numbers are bigger in both modes, so compare each app with itself, not with the other.

The bigger lever is the size of your tool list. This mock's 21 tools take 1,730 tokens. A 99-tool production server we measured takes 68,286 tokens, about 690 per tool. At that size, any app that loads every definition pays for it on every request, and a CLI's on-demand help looks much better. That's why published benchmarks against large servers report MCP costing many times more, while a right-sized tool list closes most of the gap. Public studies agree that the agent app matters more than the interface: see the controlled study across seven agent apps and Scale Labs' comparison.

Errors and discovery

All 20 CLI runs started the same way: acme --help. A command-level --help followed in 8 of 10 Claude Code runs and 4 of 10 Codex runs. Claude Code sometimes guessed first. Asked who works on a task, it tried acme get-item --id it015, got “item_id is not valid”, then read the help and used --item-id. That happened in 3 of 10 Claude Code CLI runs (4 errors), and every run recovered. Through MCP the model had the schema, so the same lookups had 0 errors.

Two practical lessons for CLI authors:

Which to build

A rule of thumb from these runs
If your users…Build
Work in coding agents with a shell (Claude Code, Codex, OpenCode)Either works for read jobs; a CLI is enough if its help is good
Use chat apps or assistants without a shellMCP: a CLI isn't reachable
Use bothBoth, generated from one core so names, descriptions and results match
Need a big API surfaceKeep the MCP tool list small or deferred; a big list is what makes MCP expensive

Whichever you pick, the work that moves results is the same: names and first lines in users' words, small default results, and errors that teach. That's the subject of how to optimise your MCP tools by knowing how agents call them.

Go deeper: How agent apps load MCP tools, How many MCP tools is too many.

How we measured

FAQ

Is MCP or CLI better for AI agents?

In our test neither was better at getting the job done: Claude Code and Codex passed 10 of 10 runs through both an MCP server and a CLI built from the same code. Differences were in cost and errors, and they depended on the agent app.

Does MCP use more tokens than a CLI?

It depends on the tool list size and the app. With a 21-tool server (1,730 tokens of tool definitions), Claude Code used about 30% fewer tokens via MCP, and Codex about 7% more, both within run-to-run spread. Large tool lists push MCP's cost up because apps that don't defer tools send the definitions with every request.

Why do agents make more errors with a CLI?

The CLI gives the agent no schema up front, so it reads --help or guesses flags. Claude Code guessed a flag name and got argument errors in 3 of 10 CLI runs, then fixed them after reading help. Through MCP, with a typed schema, it made none.

Should I build an MCP server or a CLI?

If your users work in coding agents with a shell, a CLI works as well as MCP for read jobs. Chat apps and IDE assistants without a shell need MCP. If you serve both, generate both from one core so names, descriptions and results stay the same.

Do agents use a CLI without being told?

In our runs the prompt named the CLI. Agents didn't need any other instructions: every CLI run began by reading acme --help and found the right commands from there.

Find out whether your CLI or MCP server works for agents.

We run your users' real jobs through Claude Code, Codex and the other apps they use, against your MCP server, your CLI or both, and report pass rates, tokens and failures with confidence ranges.

Test your CLI or MCP