Skip to main content
Glama
haasonsaas
by haasonsaas

cache_clear

Remove all entries from the cache or target a specific namespace to optimize storage and performance. Ideal for managing cached data effectively.

Instructions

Clear all entries from the cache or a specific namespace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceNoClear only this namespace, or all if not specified

Implementation Reference

  • Handler for the cache_clear tool: clears all entries in the shared cache Map and returns the count of cleared entries in a text content response.
    case "cache_clear": { const size = cache.size; cache.clear(); return { content: [{ type: "text", text: JSON.stringify({ success: true, cleared_entries: size }) }] }; }
  • src/index.ts:136-143 (registration)
    Tool registration entry for cache_clear in the tools array returned by listTools, defining name, description, and input schema (no parameters).
    { name: "cache_clear", description: "Clear all entries from the cache", inputSchema: { type: "object", properties: {} } },
  • Handler for cache_clear in v2 implementation: supports clearing a specific namespace (prefix-based) or the entire cache, returns cleared count.
    case "cache_clear": { const { namespace } = args as any; if (namespace) { let cleared = 0; const prefix = `${namespace}:`; for (const key of cache.keys()) { if (key.startsWith(prefix)) { cache.delete(key); cleared++; } } return { content: [{ type: "text", text: JSON.stringify({ success: true, namespace, cleared_entries: cleared }) }] }; } else { const size = cache.size; cache.clear(); return { content: [{ type: "text", text: JSON.stringify({ success: true, cleared_entries: size }) }] }; } }
  • Tool registration for cache_clear in v2 tools array, with schema supporting optional namespace parameter.
    { name: "cache_clear", description: "Clear all entries from the cache or a specific namespace", inputSchema: { type: "object", properties: { namespace: { type: "string", description: "Clear only this namespace, or all if not specified" } } } },
  • Shared cache storage Map used by cache_clear and other cache tools.
    const cache = new Map<string, CacheEntry>();

Other Tools

Related Tools

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/haasonsaas/mcp-utility-tools'

If you have feedback or need assistance with the MCP directory API, please join our Discord server