Skip to main content
Glama

clear_cache

Remove specific or all cached entries from the Memory Cache Server to free up memory and ensure data freshness during language model interactions.

Instructions

Clear specific or all cache entries

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyNoSpecific key to clear (optional - clears all if not provided)

Implementation Reference

  • MCP tool handler for 'clear_cache': handles optional 'key' argument, calls cacheManager.delete(key) if provided or cacheManager.clear() otherwise, and returns appropriate success/error text response.
    case 'clear_cache': { const { key } = request.params.arguments as { key?: string }; if (key) { const success = this.cacheManager.delete(key); return { content: [ { type: 'text', text: success ? `Successfully cleared cache entry: ${key}` : `No cache entry found for key: ${key}`, }, ], }; } else { this.cacheManager.clear(); return { content: [ { type: 'text', text: 'Successfully cleared all cache entries', }, ], }; } }
  • Tool definition including name, description, and input schema for 'clear_cache' used in ListTools response (serves as registration and schema).
    { name: 'clear_cache', description: 'Clear specific or all cache entries', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Specific key to clear (optional - clears all if not provided)', }, }, }, },
  • CacheManager.delete(key) method: removes specific cache entry if exists, updates stats, returns success boolean.
    delete(key: string): boolean { const entry = this.cache.get(key); if (entry) { this.stats.memoryUsage -= entry.size; this.cache.delete(key); this.stats.totalEntries = this.cache.size; return true; } return false; }
  • CacheManager.clear() method: clears all cache entries and resets statistics.
    clear(): void { this.cache.clear(); this.resetStats(); }

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