sf_cache_refresh
Refresh the Salesforce CLI command cache by re-scanning all available commands, ensuring accurate and up-to-date command execution for AI agents and tools interacting with Salesforce orgs.
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)Registers the sf_cache_refresh tool with the MCP server. The inline handler calls refreshCommandCache() and formats the 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 (handler)Main handler logic for refreshing the SF command cache: clears existing cache, fetches all 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)Lists sf_cache_refresh as a reserved tool to prevent dynamic registration conflicts during SF command discovery.const reservedTools = ['sf_cache_clear', 'sf_cache_refresh'];