Skip to main content
Glama

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
NameRequiredDescriptionDefault
fileAbsolutePathYesThe absolute path of the Excel file to clear from cache

Implementation Reference

  • 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" }) }] }; } }
  • 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")
  • 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);

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/zhiwei5576/excel-mcp-server'

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