Skip to main content
Glama
little2512
by little2512

clear_cache

Clear cached data from the Word Document Reader MCP Server to free up resources and ensure accurate document processing. Specify what to clear: all data, documents only, or search indexes.

Instructions

清空所有缓存

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNo清除类型:all, document, indexall

Implementation Reference

  • Main execution logic for the clear_cache tool. Handles input 'type' parameter to selectively clear document cache, index, or all caches (including memory cache via documentCache.flushAll()), and returns a success message.
    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)
    Tool registration in ListToolsRequestSchema handler, defining name, description, and input schema for clear_cache.
    { name: "clear_cache", description: "清空所有缓存", inputSchema: { type: "object", properties: { type: { type: "string", description: "清除类型:all, document, index", enum: ["all", "document", "index"], default: "all" } } } },
  • CacheManager.clear() method: Clears file-based document cache by removing all cache files (except metadata.json) and resetting metadata.
    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: Clears the full-text index Map and documents Map, updates lastUpdated timestamp.
    clear() { this.index.clear(); this.documents.clear(); this.lastUpdated = Date.now(); }
  • documentCache NodeCache instance used for in-memory document storage, cleared via flushAll() in the handler.
    const documentCache = new NodeCache({ stdTTL: 3600, // 1小时缓存 checkperiod: 600, // 每10分钟检查过期缓存 useClones: false });

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