Skip to main content
Glama

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

Implementation Reference

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

Other Tools

Related Tools

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