From 594 MCP tools to one terminal and a measured memory
Between 21 and 23 November 2026 I rebuilt how my agents reach my services (Badulaque) and my shared memory (cli-memoria). Every change was measured read-only against my own data (Claude Sonnet, no local tools, multiple runs per suite) and checked against recent research.
The honest takeaway: one decision drove the big cost drop — replacing an MCP tool search with a sandboxed terminal and CLIs (−66% cost). Everything after improved reliability or cleanliness rather than the bill; and with small samples, differences under ~10% can be noise (production against itself varied by 7%).
Summary of three days of benchmarks with Claude Sonnet over real data.
1. From 594 tools to one terminal
Premise: exposing all my services as plain MCP meant 594 tools (~742,000 characters, ~170,000 tokens per call). A tool search (RAG-MCP, 2025) cut that floor to ~2,700 tokens, yet every intermediate result still passed through the model.
Architecture shift: one single tool — a sandboxed terminal with CLIs — applying CodeAct (ICML 2024), The Bitter Lesson of Tool Calling (2026) and Beyond Plain MCP (2026: 70–90% fewer tokens and +22–40 success points from declaring output shapes).
Total: −66% cost (50.5 → 17.0 ¢), −71% calls (35 → 10), −92% context (170,300 → 14,000 chars) and −41% time (71.6 → 42.5 s). The 31-call spike came from one task missing an example in the guide (16 calls → 1).
Claude Code: ~8,000The MCP: ~4,800The task: ~300
Even with zero tools, the harness spends ~4,000 tokens per call (Prompt-Induced Waste, 2026). The real win is multi-step work: the compound task dropped from 126,000 tokens and 9 calls to 30,000 and 3.
Two interface rules mattered almost as much as sandboxing: the guide must fit (Claude Code truncates MCP instructions at 4,096 chars) and navigation beats truncation — blind cuts break prefix caches (Context Has a Price, 2026); ~100-line windows and corrective errors follow SWE-agent (NeurIPS 2024).
2. When the web client ignores MCP instructions
Premise: claude.ai does not always read MCP server instructions, leaving the agent guessing commands. Change: embed a brief reference inside the tool description (built per agent) and accept English aliases with typo hints.
| Setup | Calls | Failed | Correct | Tokens |
|---|---|---|---|---|
| Before | 52 | 6 | 7/10 | 38,137 |
| Reference in description + aliases | 10 | 0 | 10/10 | 10,999 |
| Same, with MCP instructions | 18 | 0 | 9/10 | 20,686 |
Total commands: 76 → 14 (33 with instructions). Live check in claude.ai (“do I have anything due today?”): from 8 commands (3 failed, skipped memory) to 5 commands, 0 failed and checking memory cleanly.
Next I tuned claude.ai’s instructions so it checks memory when relevant (6 questions × 3, validated on 5 unseen questions × 3):
3. Organising memory: four premises, two cuts
Largest note shrank from 59,551 chars to 10,584 + 6 subnotes (and three others below 11,000). Same cost (−2.3% noise, 15 × 2), fewer misses.
Tested on 15 × 4 and 15 × 3 (CIs [−27, +8%] calls and [−29, +17%] tokens). On those failures the agent never opened the map: changing the guide example likely shifted where it looked (Progressive Disclosure, Filesystem-Based Memory, EnSIMem, Memory Tax).
On 12 × 3 confidence intervals cross zero, yet it hurts nothing and curbs one-off section headings.
Fit in 2 cores and ~1.9 GB RAM across 2,736 sections (potion-multilingual-128M; e5-small: 4.4 min / 24 ms). Cancelled before testing EmbeddingGemma: lexical search beats vectors for agents (Is Grep All You Need?, Beyond Semantic Similarity, BM25 Wins), hybrid hurts 8–21% (The Fusion Tax) and rich aliases/dates help more (LongMemEval, doc2query, Academic Concept Index).
4. Hidden git, code rules and safe cleanup
Updating the cli-memoria CLI — two-step search, git modification dates and in-file line lookup (SearchWeaver, Search APIs as Decision Surfaces, 2026) — scored 60/60 against 119/120 (20 × 3), with +5% tokens inside the 7% baseline variance: capabilities, not savings.
The three integrity decisions that reshaped how agents write to memory:
(Practical aside: when adding file uploads to Badulaque’s browser, mocked browser tests passed everything, yet real uploads initially failed due to temporary-file permissions. Fixed and verified live.)
Summary: what stayed vs. what was discarded
| Decision | Measured effect | Status |
|---|---|---|
| Sandboxed terminal vs. MCP tool search | −66% cost, −71% calls, −92% context (7 × 2) | Shipped |
| Reference in description + English aliases | 7/10 → 10/10 without MCP instructions; 0 failed (5 × 2) | Shipped |
| claude.ai instructions without forced step | Memory 9/15 → 15/15 on unseen prompts (+13% tok) | Shipped |
| Forcing a help call upfront | +49% tokens for redundant work (6 × 3) | Discarded |
| Splitting notes >20,000 chars into subnotes | 28/30 → 30/30; same cost (−2.3% noise, 15 × 2) | Shipped |
| Tree index of the whole memory | CIs cross zero; one question dropped 9/10 → 4/10 | Discarded |
| Fixed section template on people notes | Indistinguishable from noise; curbs one-off headings (12 × 3) | Shipped |
| Local embeddings (hybrid retrieval) | Fit on CPU; dropped on agentic-search evidence | Discarded |
| Memory CLI + hidden git + code rules | 60/60 (+5% noise); 0/926 false blocks; warnings 48 → 32 | Shipped |
Bibliography
Tools, MCP and harnesses
- Beyond Plain MCP: Do Decision Models and Code Mode Make Tool Use Cheaper and Faster? (2026) — Code mode saves 70–90% tokens; declaring return shapes lifts success 22–40 points.
- RAG-MCP (2025) — The cost of stuffing hundreds of tools into context.
- CodeAct: Executable Code Actions Elicit Better LLM Agents (ICML 2024) — Executable code as the action space.
- The Bitter Lesson of Tool Calling (2026) — Calling tools from code matches or beats JSON on Anthropic models.
- Prompt-Induced Waste in Coding Agents: Reasoning, Effort, Harness Design, and End-to-End Cost (2026) — Harness design and redundant rules dominate real cost.
- SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering (NeurIPS 2024) — Concise output, corrective errors and ~100-line navigable windows.
- Context Has a Price (2026) — Dropping old outputs can raise cost by breaking prefix caches.
Memory structure and history
- Progressive Disclosure for LLM-Maintained Wiki Knowledge Bases (2026) — Capable agents skip large indexes and gain more from page summaries (−30 to −34% cost).
- Filesystem-Based Memory for LLM Agents (2026) — Organisation lowers search cost without improving answers; summarising while reorganising loses facts.
- EnSIMem: Entity-Structured Indexing for Long-Term Agent Memory (2026) — Structure as an address into notes, not a substitute for text.
- Memory Tax: Dissecting the Net Value of Agent Memory (2026) — Heavily structured memories often underperform searching raw text.
- LEDGER: Auditable Agent Memory Under Change (2026) — Auditable history and code rules vs. overwriting (69 vs. 27/93 on past facts).
- Memory Consolidation Flattens the Temporal Shape of User Facts (LAPSE) (2026) — Rewriting to consolidate flattens temporal nuance (210/381 pairs across 11 models).
Lexical, vector and expanded retrieval
- Is Grep All You Need? How Agent Harnesses Reshape Agentic Search (2026) — On memory tasks,
grepbeats vectors across every model-harness pair. - Beyond Semantic Similarity: Direct Corpus Interaction (2026) — Direct text interaction lifts accuracy from 69% to 80% at 29% lower cost.
- BM25 Wins at Scale (2026) — Agent + BM25 beats vector and graph approaches (69.4 vs. 36.9).
- The Fusion Tax: When Hybrid Retrieval Hurts (IEEE Access 2026) — Hybrid retrieval degrades 8–21% of queries.
- LongMemEval (ICLR 2025) — Expanding memory keys (+9.4% retrieval, +5.4% accuracy) and date indexing (+7–11% on temporal queries).
- Document Expansion by Query Prediction (doc2query) (2019) — Index-time document expansion.
- Improving Scientific Document Retrieval with Academic Concept Index (2026) — Concept indexing at index time.
- EmbeddingGemma (2025) — Top sub-500M model on multilingual MTEB; candidate cancelled when vectors were dropped.
- Let Agents Design How They Search (SearchWeaver) (2026) — Name index + in-file lookup (+7 points, −22 to −42% time).
- Similar Accuracy, Unequal Evidence: Search APIs as Decision Surfaces (2026) — Search snippets steer the agent’s next move; stale or contradictory results mislead it.