cache_delete
Remove specific keys from the cache to manage and optimize storage. Specify the key and optional namespace for precise deletion in MCP workflows.
Instructions
Delete a key from the cache
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Cache key to delete | |
| namespace | No | Optional namespace | default |
Implementation Reference
- src/index-v2.ts:463-480 (handler)The handler function for the 'cache_delete' tool. It extracts the key and optional namespace from arguments, computes the full cache key using getCacheKey helper, deletes the entry from the cache Map if it exists, and returns a JSON response indicating success and whether the key existed.case "cache_delete": { const { key, namespace = "default" } = args as any; const cacheKey = getCacheKey(key, namespace); const existed = cache.delete(cacheKey); return { content: [{ type: "text", text: JSON.stringify({ success: true, key, namespace, existed }) }] }; }
- src/index-v2.ts:144-162 (schema)The tool definition including name, description, and input schema for 'cache_delete'. This is part of the tools array returned by the listTools handler, effectively registering the tool.{ name: "cache_delete", description: "Delete a key from the cache", inputSchema: { type: "object", properties: { key: { type: "string", description: "Cache key to delete" }, namespace: { type: "string", description: "Optional namespace", default: "default" } }, required: ["key"] } },
- src/index-v2.ts:274-276 (helper)Helper function to generate a namespaced cache key, used by cache_get, cache_put, and cache_delete handlers.function getCacheKey(key: string, namespace: string = "default"): string { return `${namespace}:${key}`; }
- src/index.ts:324-339 (handler)Alternative implementation of the 'cache_delete' handler in index.ts (v1), without namespace support. Deletes the key from cache and returns status.case "cache_delete": { const { key } = args as { key: string }; const existed = cache.delete(key); return { content: [{ type: "text", text: JSON.stringify({ success: true, key, existed }) }] }; }
- src/index.ts:122-135 (schema)Tool schema definition for 'cache_delete' in the v1 index.ts file.{ name: "cache_delete", description: "Delete a key from the cache", inputSchema: { type: "object", properties: { key: { type: "string", description: "Cache key to delete" } }, required: ["key"] } },