sf_cache_refresh
Refresh Salesforce CLI command cache by re-scanning all available commands to ensure accurate command availability and functionality.
Instructions
Refresh the SF command cache by re-scanning all available commands
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:34-46 (registration)Registration of the 'sf_cache_refresh' tool, including empty input schema and the inline handler function that calls refreshCommandCache() and returns a formatted text response.server.tool('sf_cache_refresh', 'Refresh the SF command cache by re-scanning all available commands', {}, async () => { const result = refreshCommandCache(); return { content: [ { type: 'text', text: result ? 'Command cache refreshed successfully. Restart the server to use the new cache.' : 'Failed to refresh command cache.', }, ], }; });
- src/index.ts:34-46 (handler)The MCP tool handler function for 'sf_cache_refresh' that invokes refreshCommandCache and formats success/error response.server.tool('sf_cache_refresh', 'Refresh the SF command cache by re-scanning all available commands', {}, async () => { const result = refreshCommandCache(); return { content: [ { type: 'text', text: result ? 'Command cache refreshed successfully. Restart the server to use the new cache.' : 'Failed to refresh command cache.', }, ], }; });
- src/sfCommands.ts:101-124 (helper)Core helper function that implements the cache refresh logic: deletes existing cache, fetches all SF commands via getAllSfCommands(), and saves new cache via saveCommandCache().export function refreshCommandCache(): boolean { try { // Clear existing cache if (fs.existsSync(CACHE_FILE)) { fs.unlinkSync(CACHE_FILE); } // Create a fresh cache console.error('Refreshing SF command cache...'); // Get all commands directly from sf commands --json const commands = getAllSfCommands(); console.error(`Found ${commands.length} total commands for cache refresh`); // Save the cache saveCommandCache(commands); console.error('Cache refresh complete!'); return true; } catch (error) { console.error('Error refreshing command cache:', error); return false; } }
- src/sfCommands.ts:680-680 (helper)List of reserved tool names that are excluded from dynamic SF command registration to avoid conflicts.const reservedTools = ['sf_cache_clear', 'sf_cache_refresh'];