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

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