Skip to main content

Your Infra MCP Server Is grep+read: What Semble's 98% Token Cut Teaches Tool Builders

9 min readDora NodaDora Noda
Share
On this page

The most expensive line item in your AI-agent bill is not the model. It is the JSON you hand it.

MinishLab's Semble made that point impossible to ignore. Its Show HN launch — code search for agents, benchmarked at 98% fewer tokens than grep+read while keeping 99% of a 137M-parameter transformer's retrieval quality — climbed into the hundreds of upvotes because every engineer running Claude Code recognized the disease it cures: watching an agent grep a repo, read five whole files, and burn a six-figure token context to answer a question one function could have settled.

Infrastructure MCP servers have the same disease, one layer down. Where the coding agent cats the whole repo, the ops agent dumps the whole cluster: kubectl get pods -A -o json into the context window, 200 lines of log tail "just in case," the full Deployment object to report three ready replicas. I measured what that costs with a tokenizer, at three fleet scales, against chunked equivalents. Here is the bill, at Sonnet's standard $3 per million input tokens, per 100 agent operations:

ResponseNaive dumpChunked replyCutCost per 100 ops, naive → chunked
Fleet state, 10 pods6,608 tokens392 tokens94.1%$1.98 → $0.12
Fleet state, 50 pods32,968 tokens1,952 tokens94.1%$9.89 → $0.59
Fleet state, 200 pods131,818 tokens7,802 tokens94.1%$39.55 → $2.34
Deploy status, 1 Deployment338 tokens43 tokens87.3%$0.10 → $0.01
Pod logs, last 200 lines13,600 tokens182 tokens98.7%$4.08 → $0.05

Two things to notice before the technique. First, the naive column scales with the fleet, not the question: asking "are my pods healthy" costs 20x more at 200 pods than at 10, for an answer of identical information content. Second, the log row lands at 98.7% — basically Semble's number — without any machine learning at all. That is the whole thesis: Semble's headline result comes less from exotic retrieval than from refusing to put unranked, unchunked text in front of the model. Everything below is how to steal that refusal for deploy status, logs, and fleet state.

Methodology note: counts measured locally with the cl100k tokenizer as a proxy; ratios transfer across frontier tokenizers. Naive payloads mirror real kubectl -o json shapes (metadata, managedFields, full spec/status); chunked replies keep name/phase/restarts/age per pod, ready-count/image/revision per Deployment, and the 5 matching log lines with context.

What Semble actually did

Semble's pipeline has four stages, none of them magic. It splits each file into code-aware chunks with tree-sitter instead of fixed line windows. It scores every query against those chunks with two complementary retrievers: static embeddings from the code-specialized potion-code-16M model (built on MinishLab's Model2Vec, so there is no transformer running at query time) for semantic similarity, plus BM25 for lexical matches on identifiers and API names. It fuses the two rankings with Reciprocal Rank Fusion. It returns only the winning chunks.

The benchmark behind the headline: roughly 1,250 query/document pairs across 63 repos and 19 languages, NDCG@10 of 0.854 — on par with code-specialized transformers — while indexing an average repo in about 263 ms on CPU and answering queries with a p50 around 1–2 ms, roughly 200x faster than the transformer baseline. No GPU, no API key, no external service. The MCP server is a drop-in for Claude Code, Cursor, Codex, and OpenCode (uvx --from "semble[mcp]"), which is why the launch traveled: it was not a paper, it was a binary that made an existing workflow cheaper the same afternoon.

The design decision that matters for this post is what Semble refused to build. It did not build a bigger context window, a cheaper embedding API, or a smarter grep. It changed the unit of retrieval from the file to the chunk, ranked before returning, and treated the token budget as a first-class API constraint. Every infra tool below is the same move applied to a different corpus.

Your deploy tools are grep+read with YAML

The infra equivalent of grep + read is kubectl get everything + return the JSON. A naive get_fleet_status tool serializes every pod object — uid, resourceVersion, managedFields, last-applied-configuration annotation, full probe definitions — when the agent asked whether anything is down. A naive get_logs tool returns the whole tail when the agent asked why one request failed. The corpus differs from source code; the sin is identical: unranked, unchunked text billed by the token.

And this result tax sits on top of a second bill most teams notice first: the schema tax. Every tool definition on an MCP server costs context on every turn whether it is called or not — roughly 150 tokens per tool by one gateway author's count, and the analyses converge on ugly totals: the GitHub MCP server's 93 tools consume around 55,000 tokens, and ten servers with twenty tools each at 500 tokens apiece eats 100,000 tokens before the user has typed a word. That is why the ecosystem spent 2026 building progressive-discovery proxies — a 2-tool search/execute front that loads schemas on demand cuts the upfront cost from 10,000+ tokens to a few hundred, with research reports measuring 100–160x reductions against static registration.

Keep the two bills separate, because they have different owners. The schema tax is paid once per session and fixed with discovery plumbing. The result tax is paid per call, scales with your fleet and log volume, and is fixed only by how your tools shape replies. Semble fixed a result tax. The rest of this post is its playbook, mapped 1:1 onto infra responses.

Four stealable techniques, mapped to your tools

Semble stageCode-search formInfra-MCP form
Chunk by structure, not by bytetree-sitter splits on functions/classes, never mid-blockOne object per chunk: per-pod {name, phase, restarts, age}, per-deployment {ready, image, revision}. Never serialize a List when a summary row answers the question
Hybrid lexical + semantic retrievalBM25 catches exact identifiers, embeddings catch intentExact-match filters (pod name, label selector, error string) first, semantic/error-classifier ranking second. CrashLoopBackOff is an identifier — BM25-style matching finds it without any model call
Rank, then return top-kRRF fusion, only winners enter contextScore log lines and events by severity + recency + tenant match, return the top 5 with neighbors. My measurement: 200 lines → 5 lines, 13,600 → 182 tokens, same diagnosis
Summarize the many, keep the oneChunks, not filesAggregate the healthy ("47/50 pods Running"), itemize the sick (the 3 CrashLooping pods, full detail). Fleet-state cost then scales with problems, not pods

The last row is the one that breaks the scaling curve in the opening table. The naive fleet reply grows ~660 tokens per pod — healthy or not. The chunked reply grows ~39 tokens per healthy pod and spends detail only where the agent must act. At 200 pods that is the difference between $39.55 and $2.34 per hundred status checks, and the gap widens with every node you add. Note the failure mode this also fixes: at 131,818 tokens, the naive 200-pod dump no longer fits in a 200K window alongside the schema tax and the actual conversation. Chunking is not just cheaper; past a certain fleet size it is the only reply that fits at all.

Logs deserve a special callout because they are where teams feel the pain first. The pattern to copy is retrieve-then-read: the tool searches server-side (severity filter, exception fingerprint, tenant label), returns matching line ranges with a few lines of context, and offers a read_range follow-up instead of front-loading the whole tail. That is Semble's chunk pipeline wearing overalls, and it measured at 98.7% off — the single biggest cut in the table, for the price of a severity sort.

What not to steal: the full-fidelity exceptions

A skeptical reader should be rightly suspicious of one thing in the table above: the chunked column never contains anything the agent must reproduce verbatim. That is a rule, not an accident. Summarization is lossy, and lossy is fine for status but fatal for action. Three exceptions stay full-fidelity, always:

  • The manifest the agent will apply. Never summarize the YAML going into kubectl apply or your deploy API. A compressed paraphrase of an image tag or an env var is a misdeploy. Return it exact, or return a pointer the agent dereads verbatim.
  • The diff the agent must approve. Rollback and promotion decisions need the real before/after, not "3 replicas changed." Approval on a summary is approval theater.
  • Credentials and identifiers. UIDs, resourceVersions for optimistic writes, exact error strings for search — compress any of these and the follow-up call fails or, worse, targets the wrong object.

The general principle: chunk and rank everything the agent reads to decide; pass through verbatim everything the agent writes to act. Semble never had to draw this line because code search results are read-only. Deploy tools are read-write, so the line is the design. Put it in your tool descriptions explicitly ("this response is lossy; call get_object for the exact manifest") and agents will respect it — they already do for Semble's chunks versus read.

The takeaway for whoever owns your deploy API

Token budgets are an API design constraint now, in the same way latency and pagination are. The teams that internalize that first get a compounding advantage: every agent loop over their platform costs 10–20x less than over a competitor's, which decides how often agents poll, how many tenants an agent tier can serve, and whether continuous agent operation is economically sane at all.

If you run a self-hosted platform, audit your agent-facing surfaces the way this post audited three responses: measure one status call, one log call, and one fleet call with a tokenizer, at your actual object counts. If any of them scales with fleet size instead of answer size, you have found your grep+read. The fix is four boring stages — chunk by object, filter exactly, rank, summarize the healthy — and the benchmark for "done" is written on Semble's launch post: same answer, 98% fewer tokens.

This is the surface bex's own platform MCP server lives on: deploys, logs, and fleet state behind one streamable-HTTP endpoint, with tool names mirroring Render's MCP server where an equivalent exists. It should be held to the token-budget standard above — and so should yours. Bex.co is the open-source, AI-native Render alternative — push a git repo, get a running HTTPS service on machines you own. Star the repo on GitHub or deploy your first app today.

Related articles

Give your agents a chain backend

Autonomous agents hit RPC endpoints very differently than people do. See what bex router handles on their behalf.

Read the agents guide