Skip to main content
Glama

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; }

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