Skip to main content
Glama
topaisaas-dev

Universal Native MCP Server Hub

topai_semantic_cache

Idempotent

Store and fetch semantically matching LLM completions to skip redundant inference calls and cut latency and token spend before or after generation.

Instructions

Performs sub-5ms semantic vector cache lookups ('get') and completions storage ('set') for LLM prompts to eliminate redundant inference latency and token spend. Use before invoking an expensive upstream LLM to check if an equivalent prompt was already answered, or right after generation to cache the completion. Do not use for compressing raw text length within a single uncached prompt (use topai_token_slimmer instead). Idempotent, non-destructive edge cache operation.

Input Schema

NameRequiredDescriptionDefault
actionYesOperation mode: 'get' to retrieve a semantically matching cached response, or 'set' to store a new prompt-response pair.
promptYesThe user prompt or query string used as the semantic lookup key.
responseNoThe LLM completion text to persist in cache (required when `action` is 'set', omitted when `action` is 'get').

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.2

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare idempotentHint=true, destructiveHint=false, openWorldHint=false and readOnlyHint=false, so the safety profile is largely covered. The description nonetheless adds real context: the sub-5ms latency claim, the 'edge cache' deployment location, and which mode performs reads vs writes. It omits auth requirements, cache TTL/eviction behavior, and miss semantics, so it is strong but not exhaustive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core action, then usage, then the sibling exclusion, with no filler sentences. The trailing 'Idempotent, non-destructive edge cache operation' partially restates what the annotations already carry, which is the only mild redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With full param coverage and annotations present, the definition covers purpose, usage, exclusion, and behavior adequately for a 3-param tool. Since there is no output schema, the one remaining gap is return semantics — what 'get' yields on a cache miss and what 'set' returns on success — but the 'check if an equivalent prompt was already answered' phrasing partially implies the hit/miss model.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents action, prompt, and response fully, including the get/set enum and the response-required-only-on-set constraint. The description restates the get/set duality without adding format or syntax detail beyond the schema, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb set ('get' lookups, 'set' storage) against a named resource (semantic vector cache for LLM prompts) with a concrete performance framing (sub-5ms). It also explicitly names the sibling it is not (topai_token_slimmer), so an agent can distinguish it without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit when-to-use instructions ('before invoking an expensive upstream LLM' to check for an equivalent prompt, 'right after generation' to cache the completion) and a concrete when-not with the alternative named ('compressing raw text... use topai_token_slimmer instead'). Nothing is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.