Skip to content
sMCP~/sMCP / optimizeBY

sMCP / OPTIMIZE

Do more with each call.

A practical guide to caching, routing, batching, retrieval, output control, and deduplication.

Six ways to spend less per run

Measure the workload first: input tokens, output tokens, cache reads and writes, tool fees, retries, and latency. Change one factor, check the result against your quality bar, then measure again. Use the cost calculator with your provider's current rates.

Cache the stable prefix

Put stable instructions and deterministically ordered tool definitions at the beginning of the prompt. Keep timestamps, changing context, and the question after the cache boundary. Check actual cache-read usage; a prefix that changes on every request will not get useful hits.

Account for cache-write costs as well as cache-read discounts. The result depends on reuse, provider rules, and the cache lifetime.

Right-size the model to the turn

Route narrow classification, extraction, or formatting tasks to a model that passes your tests at lower cost. Reserve stronger reasoning for the turns that need it. Measure accuracy and failure recovery alongside token spend.

Batch work that can wait

Bulk enrichment and scheduled reports can use asynchronous provider batch APIs where available. Keep latency-sensitive interaction on the live path. Match responses by request ID and handle incomplete or failed batches explicitly.

Retrieve what matters

Index reference material and retrieve the relevant chunks for a turn instead of sending the entire corpus. Keep provenance with each chunk. Evaluate recall so reducing context does not remove the evidence needed to answer correctly.

Scope the output and effort

Ask for the result shape the next step needs, set an appropriate output ceiling, and choose an effort level that meets the task's quality bar. Remove stale tool output and dead instructions from long histories.

Avoid duplicate work

Memoize suitable deterministic results and deduplicate identical in-flight requests. Use a lookup or simple rule when it can answer reliably. Scope caches to the correct user, permissions, and data version; a cheaper response must not cross a privacy boundary.

Useful pieces for your stack

Provider prompt caching, batch APIs, token counters, vector retrieval, semantic caches, and model routers can support these tactics. They are tools you integrate into your own runtime, not permissions granted by sMCP. Confirm their behavior with the provider before relying on them.

Model the workload or return to the build guide.