clearFileCache
Clear cached data for a specified Excel file to resolve performance issues or outdated information by removing stored temporary files.
Instructions
Clear cached data for the specified Excel file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fileAbsolutePath | Yes | The absolute path of the Excel file to clear from cache |
Implementation Reference
- src/tools/cacheTools.ts:9-49 (handler)The handler function for the clearFileCache tool. Normalizes the absolute file path, checks validity, deletes the file's data from workbookCache if present, and returns a structured text response with success status or error details.async (params: { fileAbsolutePath: string }) => { try { const normalizedPath = await normalizePath(params.fileAbsolutePath); if (normalizedPath === 'error') { return { content: [{ type: "text", text: JSON.stringify({ error: `Invalid file path: ${params.fileAbsolutePath}`, suggestion: "Please verify the file path and name" }) }] }; } const deleted = workbookCache.delete(normalizedPath); return { content: [{ type: "text", text: JSON.stringify({ success: true, message: deleted ? `Cache cleared successfully for file: ${normalizedPath}` : `No cache found for file: ${normalizedPath}` }) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: `Failed to clear cache: ${error}`, suggestion: "Please verify the file path" }) }] }; } }
- src/tools/cacheTools.ts:7-7 (schema)Zod input schema defining the required 'fileAbsolutePath' parameter as a string with descriptive metadata.fileAbsolutePath: z.string().describe("The absolute path of the Excel file to clear from cache")
- src/tools/cacheTools.ts:5-50 (registration)Direct registration of the 'clearFileCache' tool on the MCP server, specifying name, description, input schema, and inline handler function.server.tool("clearFileCache", 'Clear cached data for the specified Excel file', { fileAbsolutePath: z.string().describe("The absolute path of the Excel file to clear from cache") }, async (params: { fileAbsolutePath: string }) => { try { const normalizedPath = await normalizePath(params.fileAbsolutePath); if (normalizedPath === 'error') { return { content: [{ type: "text", text: JSON.stringify({ error: `Invalid file path: ${params.fileAbsolutePath}`, suggestion: "Please verify the file path and name" }) }] }; } const deleted = workbookCache.delete(normalizedPath); return { content: [{ type: "text", text: JSON.stringify({ success: true, message: deleted ? `Cache cleared successfully for file: ${normalizedPath}` : `No cache found for file: ${normalizedPath}` }) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: `Failed to clear cache: ${error}`, suggestion: "Please verify the file path" }) }] }; } } );
- src/index.ts:25-25 (registration)Top-level invocation of cacheTools function to register cache-related tools, including 'clearFileCache', on the main MCP server instance.cacheTools(server);