← All writing

From 594 MCP tools to one terminal and a measured memory

23 November 2026

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%).

−66%cost with terminal50.5 → 17.0 ¢ (7 × 2)
10/10without MCP instructionswas 7/10 (5 × 2)
0 / 926false blockscode-enforced rules
3ideas discardedforced help, map, vectors

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).

Progression on the same 7 real tasks (×2, Claude Sonnet)
Cost (¢)CallsContext (chars) Previous tool search2 tools 50.5 35 170,300 First terminalguide cut at 4,096 chars 23.7 19.5 56,000 Navigable outputsno examples in guide 20.7 31 39,000 Current terminalshort guide + examples 17.0 10 14,000

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).

Why one-shot queries save little: ~13,100 tokens for a single command

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.

Client ignoring MCP instructions (5 questions × 2, Claude Sonnet)
SetupCallsFailedCorrectTokens
Before5267/1038,137
Reference in description + aliases10010/1010,999
Same, with MCP instructions1809/1020,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):

Forcing a help call upfront16,374 → 24,452 tokens (+49%)→✕ DiscardedRedundant work (Prompt-Induced Waste).
Final instructions without forced stepMemory 9/15 → 15/15 on unseen prompts→✓ Shipped15/15 correct; +13% tokens (simply the cost of reading memory).

3. Organising memory: four premises, two cuts

Split notes >20,000 charsShipped
28/30 → 30/30 accuracy

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.

Full tree indexDiscarded
CIs cross 0 · one dropped 9/10 → 4/10

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).

People-note templateShipped
35/36 → 36/36 (cost: noise)

On 12 × 3 confidence intervals cross zero, yet it hurts nothing and curbs one-off section headings.

Local CPU embeddingsDiscarded
1.8 s index · 0.2 ms/query

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:

Why git stays underneathOverwriting scores 27/93 on past facts vs. 69/93 with a ledger (LEDGER)→✓ Hidden gitRewriting flattens 210/381 temporal nuances (LAPSE).
Code-enforced write rules926 normal edits → 0 blocks · 389 real writes → 9 pollution writes stopped→✓ 149 testsBlocks only new violations and protects my verbatim quotes intact.
Cleaning 303 notes without rewriting817 titles (736 one-off) · 156 retired mentions → 66 lines in 38 notes→✓ Warnings 48 → 32Zero facts lost and top-5 recall unchanged (23/30).

(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

DecisionMeasured effectStatus
Sandboxed terminal vs. MCP tool search−66% cost, −71% calls, −92% context (7 × 2)Shipped
Reference in description + English aliases7/10 → 10/10 without MCP instructions; 0 failed (5 × 2)Shipped
claude.ai instructions without forced stepMemory 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 subnotes28/30 → 30/30; same cost (−2.3% noise, 15 × 2)Shipped
Tree index of the whole memoryCIs cross zero; one question dropped 9/10 → 4/10Discarded
Fixed section template on people notesIndistinguishable from noise; curbs one-off headings (12 × 3)Shipped
Local embeddings (hybrid retrieval)Fit on CPU; dropped on agentic-search evidenceDiscarded
Memory CLI + hidden git + code rules60/60 (+5% noise); 0/926 false blocks; warnings 48 → 32Shipped

Bibliography

Tools, MCP and harnesses

Memory structure and history

Lexical, vector and expanded retrieval