Skip to main content
Glama
ibproduct

Memory Cache MCP Server

by ibproduct

clear_cache

Remove specific or all cached entries to free memory and ensure fresh data retrieval in the Memory Cache MCP Server.

Instructions

Clear specific or all cache entries

Input Schema

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

Implementation Reference

  • Executes the clear_cache tool logic: deletes specific key or clears all cache via CacheManager, returns success/error messages.
    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', }, ], }; }
  • Input schema for the clear_cache tool, defining optional 'key' parameter.
    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 and 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(); }
  • src/index.ts:97-157 (registration)
    Registers the clear_cache tool in the ListToolsRequestSchema handler by including it in the tools array.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'store_data', description: 'Store data in the cache with optional TTL', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Unique identifier for the cached data', }, value: { type: 'any', description: 'Data to cache', }, ttl: { type: 'number', description: 'Time-to-live in seconds (optional)', }, }, required: ['key', 'value'], }, }, { 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'], }, }, { 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)', }, }, }, }, { name: 'get_cache_stats', description: 'Get cache statistics', inputSchema: { type: 'object', properties: {}, }, }, ], }));

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