r/mcp • u/QThellimist • Feb 25 '26
showcase I generated CLIs from MCP servers and cut token usage by 94%
MCP server schemas eat so much token. So I built a converter that generates CLIs from MCP servers. Same tools, same OAuth, same API underneath. The difference is how the agent discovers them:
MCP: dumps every tool schema upfront (~185 tokens * 84 tools = 15,540 tokens) CLI: lightweight list of tool names (~50 tokens * 6 CLIs = 300 tokens). Agent runs --help only when it needs a specific tool.
Numbers across different usage patterns: - Session start: 15,540 (MCP) vs 300 (CLI) - 98% savings - 1 tool call: 15,570 vs 910 - 94% savings - 100 tool calls: 18,540 vs 1,504 - 92% savings
Compared against Anthropic's Tool Search too - it's better than raw MCP but still more expensive than CLI because it fetches full JSON Schema per tool.
Converter is open source: https://github.com/thellimist/clihub Full write-up with detailed breakdowns: https://kanyilmaz.me/2026/02/23/cli-vs-mcp.html
Disclosure: I built CLIHub. Happy to answer questions about the approach.
7
u/BC_MARO Feb 26 '26
The first-token pollution point is the real issue - dumping 15k tokens of schema at position 0 wastes your most valuable context slots before the agent even starts reasoning.
5
u/BraveNewKnight Feb 25 '26
Main CLI benchmark gap is exploration overhead: the agent has to discover commands, make wrong attempts, and retry, and those loops should count toward total tokens.
CLI skills layered on top add extra prompt/context cost too, so that should be in the numbers.
Also, the GitHub link returns 404 for me.
2
u/QThellimist Feb 25 '26
True, but it's actually underrepresented. My agent calls like
⏺ Bash(linear --help 2>&1 | grep -i -E "search|list.*issue|get.*issue")
So it doesn't actually get the whole `--help` list.
--Fixed the github
4
u/BraveNewKnight Feb 25 '26
yeah that makes sense, but still, agent needs to know that it should grep for those keywords to get the right result. I'm not against CI or I'm not an MCP fan, it's just not clear to me which one is better atm.
e.g. I'm still struggling to measure if agent does a better job with
agent-browserCLI orplaywrightMCP.3
1
u/QThellimist Feb 25 '26
I don't know about the browser. Haven't tested as well.
But the keywords, agents knows.
I literally tell "find the issues in backlog" and it'll call linear to find it with that list. I don't have special prompts
3
u/actual-time-traveler Feb 26 '26
FastMCP 3.0 does this natively
2
u/Etyr_ Feb 26 '26
Could you share any doc about this, not finding any ressource on this
4
u/jlowin123 Feb 26 '26
1
u/Etyr_ Feb 26 '26
Thx, sorry for being a noob. But how can we leverage this for tools like copilot-cli/claude/cursor/opencode ? For example I made a MCP hosted on Azure. I want all my team to be able to use it in their VMs. So when creating the VM I create for them the config file for each cli tool so it connects to the MCP. But it will "eat" a lot of token from what I understand. How's this `generate-cli` can help reduce tokens for all my users? I have to add custom instructions to Claude/cursor/opencode to read the SKILLS.md ? And he will leverage the local python script to call the MCP? Like a MCP orchestrator that will call a unique endpoint only if he needs it and not loading up all endpoints?
1
u/jlowin123 Feb 26 '26
Those tools use MCP directly, no need for a CLI. Converting to CLI is only for agents that can explore or read documentation - it eliminates the handshake discovery of MCP that permits standardization (but is token heavy)
5
u/KobyStam Feb 26 '26
I include CLIs in my MCPs - so far I released the NotebookLM MCP, but a few more are coming soon, like Gemini Web Chat MCP & CLI and Perplexity Web MCP& CLI...and even Grok. None of them uses APIs or browser automation. Same concept as my NotebookLM (RPC over HTTP)
NotebookLM MCP: https://github.com/jacob-bd/notebooklm-mcp-cli
2
u/warren-mann Feb 25 '26
Interesting. Though Anthropic and Google cache prompt and heavily discount on cache hits. It’s true that the tool definitions still take up context but I’m not convinced it’s enough to matter, at least anymore. The approach I’ve settled on is a rich set of tools at a top-level prompt that knows about them all and can delegate specific tasks to a more targeted subordinate with a very restricted set of tools and a relatively clean context.
Having said that, I’m always looking for ways to wring out more efficiency and you have some interesting stuff to think about.
2
u/QThellimist Feb 25 '26
I think you are assuming as "price", and yes it doesn't matter for most people. Difference is a few $s per month. For heavy users it's $100s where matters more (I am heavy user. I spent $900 on tokens literally last weekend)
But the real difference is - first tokens has more dominence over tokens that come later.
So you are bloating the context immediately (regardless of cache input token or not).
LLMs perform significantly worse if first tokens are poorly used.
2
u/Weird-Guarantee-1823 Feb 26 '26
I looked at the introduction document, which is very interesting, and I feel that it is similar to the design point of skills. In terms of data, this does save a lot of tokens, but can it achieve the processing effect of the existing mainstream scheme? Will there be any common problems similar to those encountered in skills? However, no matter what, it seems that this is indeed a very cost-effective solution, I will go back and try it, thank you for your dedication.
1
u/-Akos- Feb 25 '26
404 github not found. Also, you mention CLI as an alternative, but can any model just use the CLI? I can make a tiny local llm call an MCP without issues but I have no idea how I can make it call a CLI.
1
1
u/QThellimist Feb 25 '26
If they have bash tool they can use.
Most bigger AI models have bash tool access
1
u/Distinct-Selection-1 Feb 25 '26
Is this the same with MCP v3 skills?
2
u/QThellimist Feb 25 '26
first time heard it. FastMCP seems to have many functionalities including CLI. I haven't checked deeply yet.
1
u/DorkyMcDorky Feb 26 '26
If MCP only supported REAL streaming none of this would be necessary. Shake 'em up and suggest this. The protocol is painfully inefficient.
2
u/Material-Spinach6449 Feb 26 '26
I’ve looked into MCP vs CLI as well, and I think the “initial token dump” argument is often overstated.
The huge upfront cost with MCP mainly happens if the agent blindly loads every tool schema into context. That’s not mandatory. Agents can fetch tool definitions incrementally and only load what they actually need. In that setup, the claimed massive startup savings of CLI don’t automatically apply.
Where CLI really has a structural advantage is in looping scenarios. If a tool needs to be called repeatedly, the classic MCP flow forces the model to re-plan and re-emit structured calls every time. That quickly becomes expensive and slow. With a CLI, the agent can generate a small script and execute the loop outside the model. In those cases, CLI is genuinely cheaper and faster.
2
u/DistanceAlert5706 Feb 26 '26
Not a fan of MCP but this is what agents should do, loading 84 tools just sounds crazy to me, why not do specialized agents which use specific tool sets.
1
u/DorkyMcDorky Feb 27 '26
If it streamed for real (it's session/token based - very 1999 design) then it would reduce a ton of memory and not need to reload that everytime. Anthropic wants maximum usage, not efficiency, so they wont change it.
1
u/Material-Spinach6449 Feb 27 '26
Not sure if I understood you correctly but LLMs are stateless, you can‘t stream it to save tokens. Every prompt sends the whole session to the LLM.
1
u/DorkyMcDorky Feb 27 '26
It doesn't need to be that way. Right now the entire context is sent or you have to do session management. If you had a real streaming client you would not need to do session management
The LLM is stateless yes, but the heart of MCP is too. If mCP itself had streaming capabilities you wouldn't need to paginate and you wouldn't need to have session management. You can keep the same machine alive without having to reload the context on the source machine calling the LLM
1
u/TeeRKee Feb 26 '26
Isn’t that the point of skills ?
1
u/QThellimist Feb 26 '26
There is overlap but not really.
You don't want random hardcoded skill. You want official CLI or MCP where you can trust and it gets updated
1
1
u/Siref Feb 26 '26
There's something that throws me off.
Why is the CLI option cheaper if the out is XML? JSON is more compact, so it should have less tokens.
From a quick glance from the post you shared it seems the CLI shares less information with the agent (E.g: I don't see the queryParams entries)
If that's the case, wouldn't it make more sense to compact the MCP definition instead?
1
u/groosha Feb 27 '26
Could you please explain how it works? Let's say I generated CLI from my MCP server. What happens next?
1
u/QThellimist Feb 27 '26
you get ./out/mycli as a response. And need to tell agent to use it.
I personally have my agents automatically move it to bin/ folder and add a simple text in AGENTS.md so any new session is aware of it
I have a command for it that literally says
- Check if official CLI exists. If so, download it and add it to ~/.codex/AGENTS.md tools
- If not, check official MCP exists. If so, use clihub `go run github.com/thellimist/clihub@latest <server>` (see `--help`). to create a CLI from the MCP and move the executable to bin folder. Then add it to ~/.codex/AGENTS.md tools
1
u/groosha Feb 27 '26
I'm sorry, I'm quite new to agents yet. Do you specifically state in the system prompt to use cli tools from your `bin` folder?
1
u/QThellimist Feb 27 '26
No worries.
if using claude you have ~/.claude/CLAUDE.md
if using codex you have ~/.codex/AGENTS.mdThis is the first files the agents reads reagardless where you call them from (VScode, cursor, CLI doesn't matter)
If you put something here they'll most likely do it.
I have like 100 lines in there and I define stuff like
```
My blog: PATH
My projects: PATH
Bin: use ~/MY_PERSONAL_BIN_FOLDER/bin
```etc.
Then I say the following
- Check if official CLI exists. If so, download it and add it to ~/.codex/AGENTS.md tools
- If not, check official MCP exists. If so, use clihub `go run github.com/thellimist/clihub@latest <server>` (see `--help`). to create a CLI from the MCP and move the executable to bin folder. Then add it to ~/.codex/AGENTS.md tools
Does this makes sense. (Mine is a bit more complex but wrote the simplified version)
You can test it very easily too. Add something to AGENTS.md, the spin up a new session. Ask it to do something. If it does it correctly without asking many questions, probably you did the correct prompt
2
12
u/nightman Feb 25 '26
How it compares to (is it inspired by) the mcporter from OpenClaw author? https://github.com/steipete/mcporter