Skip to main content
Glama
little2512

Word Document Reader MCP Server

by little2512

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
NameRequiredDescriptionDefault
typeNo清除类型:all, document, indexall

Implementation Reference

  • 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"
          }
        }
      }
    },
  • 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"
        }
      }
  • 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, {});
    }
  • 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();
    }

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