Skip to main content
Glama
ibproduct

Memory Cache MCP Server

by ibproduct

retrieve_data

Retrieve cached data using a key to access stored information and reduce redundant token usage in 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. It extracts the key from the request arguments, calls cacheManager.get(key) to retrieve the data, and returns either the JSON-stringified value or an error message 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),
          },
        ],
      };
    }
  • src/index.ts:122-134 (registration)
    Tool registration object defining the name, description, and input schema for 'retrieve_data', returned by 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'],
      },
    },
  • Input schema validation for the 'retrieve_data' tool, requiring a 'key' string.
    inputSchema: {
      type: 'object',
      properties: {
        key: {
          type: 'string',
          description: 'Key of the cached data to retrieve',
        },
      },
      required: ['key'],
    },
  • The CacheManager.get(key) method implements the core data retrieval logic: checks for existence and expiration, updates access statistics, and returns the cached value if valid.
    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 tool retrieves data, implying a read-only operation, but doesn't disclose behavioral traits like error handling (e.g., what happens if the key doesn't exist), performance aspects, or any side effects. The description is minimal and lacks critical operational details.

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?

The description is a single, efficient sentence with no wasted words, making it front-loaded and easy to parse. However, it's overly concise to the point of under-specification, which slightly reduces its effectiveness. Every word earns its place, but more detail could improve clarity.

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 tool has no annotations and no output schema, the description is incomplete. It doesn't explain what the retrieved data looks like, potential return values, or error conditions. For a retrieval tool with one parameter, more context is needed to guide effective use, making this description inadequate.

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 clearly documented. The description adds no additional meaning beyond the schema, such as examples of key formats or constraints. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 is clear but basic. It doesn't distinguish this tool from its sibling 'get_cache_stats', which might also retrieve cache-related information. The purpose is understandable but lacks specificity about what type of data or scope is involved.

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?

The description provides no guidance on when to use this tool versus alternatives like 'store_data' or 'clear_cache'. It doesn't mention prerequisites, such as needing data to be cached first, or context for when retrieval is appropriate versus other cache operations. Usage is implied but not explicitly stated.

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/ibproduct/ib-mcp-cache-server'

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