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

  • MCP tool handler for 'retrieve_data': extracts key from arguments, retrieves value using CacheManager.get(), returns JSON string or 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), }, ], }; }
  • Input schema definition for the retrieve_data tool, specifying required 'key' parameter.
    inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Key of the cached data to retrieve', }, }, required: ['key'], },
  • src/index.ts:121-134 (registration)
    Registration of the retrieve_data tool in the ListTools response, including name, description, and schema.
    { 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'], }, },
  • CacheManager.get method: retrieves entry by key, checks expiration, updates access time and statistics, returns value or undefined.
    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; }

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