sf_cache_clear
Clear cached Salesforce CLI command metadata to refresh and ensure up-to-date command execution and data management.
Instructions
Clear the cached SF command metadata to force a refresh
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:20-32 (handler)The execution handler for the sf_cache_clear tool. It calls clearCommandCache() from sfCommands.ts and returns a formatted text response indicating success or failure.server.tool('sf_cache_clear', 'Clear the cached SF command metadata to force a refresh', {}, async () => { const result = clearCommandCache(); return { content: [ { type: 'text', text: result ? 'Command cache cleared successfully.' : 'Failed to clear command cache or cache did not exist.', }, ] }; });
- src/sfCommands.ts:82-96 (helper)The core helper function that implements the cache clearing logic by deleting the command cache JSON file at ~/.sf-mcp/command-cache.json.export function clearCommandCache(): boolean { try { if (fs.existsSync(CACHE_FILE)) { fs.unlinkSync(CACHE_FILE); console.error(`Removed cache file: ${CACHE_FILE}`); return true; } else { console.error(`Cache file does not exist: ${CACHE_FILE}`); return false; } } catch (error) { console.error('Error clearing command cache:', error); return false; } }
- src/index.ts:20-32 (registration)Registers the sf_cache_clear tool on the MCP server with no input schema and the handler function.server.tool('sf_cache_clear', 'Clear the cached SF command metadata to force a refresh', {}, async () => { const result = clearCommandCache(); return { content: [ { type: 'text', text: result ? 'Command cache cleared successfully.' : 'Failed to clear command cache or cache did not exist.', }, ] }; });
- src/sfCommands.ts:680-680 (helper)Marks sf_cache_clear as a reserved tool name to prevent conflicts with dynamically registered SF CLI command tools.const reservedTools = ['sf_cache_clear', 'sf_cache_refresh'];