cache_clear
Clear all cache entries or remove data from a specific namespace to free memory and reset cached results.
Instructions
Clear all entries from the cache or a specific namespace
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | Clear only this namespace, or all if not specified |
Implementation Reference
- src/index.ts:341-354 (handler)Handler for cache_clear tool - clears all entries from the cache Map and returns the count of cleared entries.
case "cache_clear": { const size = cache.size; cache.clear(); return { content: [{ type: "text", text: JSON.stringify({ success: true, cleared_entries: size }) }] }; } - src/index-v2.ts:482-519 (handler)Enhanced handler for cache_clear tool - supports optional namespace parameter to clear only entries in a specific namespace, or clears all if no namespace provided.
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 }) }] }; } } - src/index.ts:136-143 (schema)Schema/definition for cache_clear tool in index.ts - no parameters required, clears entire cache.
{ name: "cache_clear", description: "Clear all entries from the cache", inputSchema: { type: "object", properties: {} } }, - src/index-v2.ts:163-175 (schema)Schema/definition for cache_clear tool in index-v2.ts - supports optional namespace parameter to clear only a specific namespace.
{ 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" } } } }, - src/index.ts:188-191 (registration)Tool registration via ListToolsRequestSchema handler - cache_clear is registered as part of the tools array.
// Register list handler server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });