clear_cache
Clear cached data from the Word Document Reader MCP Server to free up system resources and ensure document processing uses current information. Specify cache type: all, document, or index.
Instructions
清空所有缓存
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | 清除类型:all, document, index | all |
Implementation Reference
- server.js:820-849 (handler)The handler logic for executing the 'clear_cache' tool. It processes the input 'type' parameter and clears the appropriate caches: document cache via CacheManager.clear(), index via DocumentIndexer.clear(), or all including NodeCache.flushAll().case "clear_cache": { const { type = "all" } = args; switch (type) { case "document": await cacheManager.clear(); var clearedMessage = "已清空文档缓存"; break; case "index": documentIndexer.clear(); var clearedMessage = "已清空全文索引"; break; case "all": default: await cacheManager.clear(); documentIndexer.clear(); documentCache.flushAll(); var clearedMessage = "已清空所有缓存(文档缓存、全文索引、内存缓存)"; break; } return { content: [ { type: "text", text: clearedMessage } ] }; }
- server.js:550-564 (registration)Registration of the 'clear_cache' tool in the ListToolsRequestHandler response, including name, description, and input schema.{ name: "clear_cache", description: "清空所有缓存", inputSchema: { type: "object", properties: { type: { type: "string", description: "清除类型:all, document, index", enum: ["all", "document", "index"], default: "all" } } } },
- server.js:553-562 (schema)Input schema definition for the 'clear_cache' tool, specifying the optional 'type' parameter.inputSchema: { type: "object", properties: { type: { type: "string", description: "清除类型:all, document, index", enum: ["all", "document", "index"], default: "all" } }
- server.js:419-428 (helper)CacheManager.clear() method used by the clear_cache handler to clear document caches.async clear() { await this.initialize(); const files = await fs.readdir(this.cacheDir); for (const file of files) { if (file !== 'metadata.json') { await fs.remove(path.join(this.cacheDir, file)); } } await fs.writeJson(this.metadataFile, {}); }
- server.js:133-137 (helper)DocumentIndexer.clear() method used by the clear_cache handler to clear the full-text index.clear() { this.index.clear(); this.documents.clear(); this.lastUpdated = Date.now(); }