echocache

v0.1.3
io.github.kskurtveit/echocache Checked 4 days ago Published 3 months ago

MCP server caching expensive LLM responses: HTTP-style freshness plus semantic recall.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

cache_get

Look up a cached LLM response by exact (model, prompt, params) match, like an HTTP cache checking a request against its cache key. Call this BEFORE issuing an expensive prompt to a model. Returns hit:false on a miss or an expired entry — in that case, run the prompt yourself and store the result with cache_set. On a hit, freshness mirrors HTTP semantics: fresh means use it as-is; stale means it is past its TTL but within its stale-while-revalidate window, so you may still use it but consider refreshing it.

ParameterTypeDescription
model *stringModel/tool identifier the response came from, e.g. "claude-sonnet-5"
prompt *stringThe exact prompt or request text
paramsobjectOther call parameters that affect the response (temperature, system prompt, etc.)

cache_set

Store a prompt/response pair in the cache. Call this AFTER getting a fresh response from a model that cache_get did not have. New entries are automatically linked in a similarity graph to existing entries with related content, so cache_related and cache_query can surface them later even without an exact key match. Pass derived_from with parent entry ids if this result was built from other cached entries — invalidating a parent with cascade can then clean up anything derived from it.

ParameterTypeDescription
model *string
prompt *string
response *stringThe response text to cache
derived_fromarrayIds of parent entries this was built from
paramsobject
stale_while_revalidate_secondsintegerExtra window after TTL expiry where the entry is still returned, marked stale
tagsarray
ttl_secondsFreshness lifetime in seconds. null = never expires. Default: 1 day

cache_query

Semantic search across all cached entries, independent of exact key matching. Use this when you suspect something related was already computed even though the prompt wording differs — the knowledge-graph equivalent of a cache lookup by meaning instead of by exact key.

ParameterTypeDescription
text *stringText to search for semantically related cache entries
min_similaritynumberSimilarity floor 0-1, default 0.3
top_kintegerMax results, default 5

cache_invalidate

Delete a cache entry, e.g. because the underlying source it was based on changed. With cascade:true, also deletes every entry that declared this one as a derived_from parent, and recursively theirs — dependency-graph invalidation instead of a manual hunt for stale copies.

ParameterTypeDescription
id *string
cascadebooleanAlso delete entries derived from this one, default false

cache_stats

Cache analytics: entry/edge counts, exact-match hit rate, queryHits/queryMisses for semantic recall, and tokensServed — the token count handed back from cache. Note that tokensServed equals tokens *saved* only for entries that stand in for work which would otherwise be regenerated; serving a cached file read costs the same tokens as re-reading the file, so it saves nothing.