clearFileCache
Remove cached data for a specified Excel file to ensure accurate and updated file operations. Input the file's absolute path to trigger the cache clearance process.
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 that normalizes the file path, deletes the corresponding entry from the workbookCache if it exists, and returns a JSON-formatted success or error message via MCP content.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:6-8 (schema)Zod schema defining the input parameter 'fileAbsolutePath' as a required string.{ 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, including 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)Invocation of cacheTools function to register cache-related tools, including 'clearFileCache', on the main MCP server instance.cacheTools(server);