Skip to main content
Glama
little2512

Word Document Reader MCP Server

by little2512

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
NameRequiredDescriptionDefault

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: {}
      }
    },
  • 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
          }
        ]
      };
    }
  • 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
      };
    }
  • 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
      };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/little2512/word-doc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server