clear_memory
Remove cached data from the Word document reader to free up system resources and manage memory usage efficiently.
Instructions
清除指定的内存内容
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memoryKey | No | 要清除的内存键名,如果不提供则清除所有 |
Implementation Reference
- server.js:924-956 (handler)The handler function for 'clear_memory' tool in the main server. It removes a specific memoryKey from documentCache or flushes all if not specified, returning appropriate success/error messages.case "clear_memory": { const { memoryKey } = args; if (memoryKey) { const removed = documentCache.del(memoryKey); if (removed > 0) { return { content: [ { type: "text", text: `已清除内存键 "${memoryKey}" 的内容` } ] }; } else { throw new Error(`未找到内存键 "${memoryKey}" 的内容`); } } else { // 清除所有内存 const count = documentCache.keys().length; documentCache.flushAll(); return { content: [ { type: "text", text: `已清除所有内存内容 (共 ${count} 个文档)` } ] }; } }
- server.js:594-605 (registration)Registration of the 'clear_memory' tool including name, description, and input schema in the server's tools list.name: "clear_memory", description: "清除指定的内存内容", inputSchema: { type: "object", properties: { memoryKey: { type: "string", description: "要清除的内存键名,如果不提供则清除所有" } } } }
- server-basic.js:272-306 (handler)The handler function for 'clear_memory' tool in the basic server. It deletes from uiComponentMemory and/or documentMemory.case "clear_memory": { const { memoryKey } = args; if (memoryKey) { const removedFromUI = uiComponentMemory.delete(memoryKey); const removedFromDoc = documentMemory.delete(memoryKey); if (removedFromUI || removedFromDoc) { return { content: [ { type: "text", text: `已清除内存键 "${memoryKey}" 的内容` } ] }; } else { throw new Error(`未找到内存键 "${memoryKey}" 的内容`); } } else { // 清除所有内存 const count = uiComponentMemory.size + documentMemory.size; uiComponentMemory.clear(); documentMemory.clear(); return { content: [ { type: "text", text: `已清除所有内存内容 (共 ${count} 个文档)` } ] }; } }
- server-basic.js:109-120 (registration)Registration of the 'clear_memory' tool including name, description, and input schema in the basic server's tools list.name: "clear_memory", description: "清除指定的内存内容", inputSchema: { type: "object", properties: { memoryKey: { type: "string", description: "要清除的内存键名,如果不提供则清除所有" } } } }