get_cache_stats
Retrieve cache statistics to monitor performance and optimize document processing efficiency in the Word Document Reader MCP Server.
Instructions
获取缓存统计信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.js:542-549 (registration)Registration of the 'get_cache_stats' tool in the ListTools response, including name, description, and empty input schema.{ name: "get_cache_stats", description: "获取缓存统计信息", inputSchema: { type: "object", properties: {} } },
- server.js:797-818 (handler)Handler for the 'get_cache_stats' tool: retrieves stats from CacheManager and DocumentIndexer instances, formats a detailed stats text response including document cache size and index stats.case "get_cache_stats": { const documentStats = await cacheManager.getStats(); const indexStats = documentIndexer.getStats(); const statsText = `缓存统计信息:\n\n` + `文档缓存:\n` + `- 缓存文件数: ${documentStats.totalCached}\n` + `- 总缓存大小: ${(documentStats.totalSize / 1024 / 1024).toFixed(2)} MB\n\n` + `全文索引:\n` + `- 索引词汇数: ${indexStats.totalWords}\n` + `- 索引文档数: ${indexStats.totalDocuments}\n` + `- 最后更新: ${new Date(indexStats.lastUpdated).toLocaleString()}`; return { content: [ { type: "text", text: statsText } ] }; }
- server.js:430-440 (helper)CacheManager.getStats(): Computes and returns document cache statistics including total number of cached items, total size in bytes, and metadata.async getStats() { await this.initialize(); const metadata = await fs.readJson(this.metadataFile); const keys = Object.keys(metadata); return { totalCached: keys.length, totalSize: keys.reduce((sum, key) => sum + (metadata[key].size || 0), 0), files: metadata }; }
- server.js:140-146 (helper)DocumentIndexer.getStats(): Returns full-text index statistics: total unique words, total indexed documents, and last update timestamp.getStats() { return { totalWords: this.index.size, totalDocuments: this.documents.size, lastUpdated: this.lastUpdated }; }