Skip to main content
Glama
tosin2013

Memory Cache Server

retrieve_data

Retrieve cached data from the Memory Cache Server using a specific key to access stored information during language model interactions.

Instructions

Retrieve data from the cache

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey of the cached data to retrieve

Implementation Reference

  • The main handler for the 'retrieve_data' tool. Extracts the key from the request arguments, retrieves the value using CacheManager.get(key), and returns the JSON-stringified value or an error if not found.
    case 'retrieve_data': {
      const { key } = request.params.arguments as { key: string };
      const value = this.cacheManager.get(key);
      if (value === undefined) {
        return {
          content: [
            {
              type: 'text',
              text: `No data found for key: ${key}`,
            },
          ],
          isError: true,
        };
      }
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(value, null, 2),
          },
        ],
      };
    }
  • Input schema for the 'retrieve_data' tool, defining that a 'key' string is required. Part of the tool registration in ListToolsRequestSchema handler.
    name: 'retrieve_data',
    description: 'Retrieve data from the cache',
    inputSchema: {
      type: 'object',
      properties: {
        key: {
          type: 'string',
          description: 'Key of the cached data to retrieve',
        },
      },
      required: ['key'],
    },
  • Core retrieval logic in CacheManager.get(key): fetches from Map, checks expiration, updates access time and statistics, returns the cached value.
    get(key: string): any {
      const startTime = performance.now();
      const entry = this.cache.get(key);
    
      if (!entry) {
        this.stats.misses++;
        this.updateHitRate();
        return undefined;
      }
    
      // Check if entry has expired
      if (this.isExpired(entry)) {
        this.delete(key);
        this.stats.misses++;
        this.updateHitRate();
        return undefined;
      }
    
      // Update last accessed time
      entry.lastAccessed = Date.now();
      this.stats.hits++;
      this.updateHitRate();
    
      const endTime = performance.now();
      this.updateAccessTime(endTime - startTime);
    
      return entry.value;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the action ('retrieve') but doesn't disclose behavioral traits such as error handling (e.g., what happens if the key doesn't exist), performance characteristics, or side effects. This leaves significant gaps for a tool that interacts with a cache.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary elaboration.

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

Completeness2/5

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

Given the complexity (a cache retrieval tool with no annotations and no output schema), the description is incomplete. It doesn't explain what the return value looks like, error conditions, or how it differs from siblings. This leaves the agent with insufficient information to use the tool effectively.

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?

The input schema has 100% description coverage, with the 'key' parameter fully documented. The description adds no additional meaning beyond what the schema provides (e.g., no examples or constraints). According to the rules, with high schema coverage, the baseline is 3 even without param info in the description.

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

Purpose3/5

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

The description states the action ('retrieve') and resource ('data from the cache'), which provides a basic purpose. However, it's vague about what type of data or cache is involved, and it doesn't distinguish from siblings like 'get_cache_stats' (which might also retrieve data about the cache). It's not tautological but lacks specificity.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., data must be stored first), exclusions, or comparisons to siblings like 'store_data' or 'clear_cache'. The agent must infer usage from context alone.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tosin2013/mcp-memory-cache-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server