sf_list_roots
Use this tool to list all configured Salesforce project directories and their metadata, enabling efficient management of Salesforce CLI projects and metadata.
Instructions
List all configured Salesforce project directories and their metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:93-120 (handler)Handler function for the sf_list_roots tool that retrieves and formats the list of configured Salesforce project roots.server.tool('sf_list_roots', 'List all configured Salesforce project directories and their metadata', {}, async () => { const roots = getProjectRoots(); if (roots.length === 0) { return { content: [ { type: 'text', text: 'No project roots configured. Use sf_set_project_directory to add a project root.' } ] }; } // Format roots list for display const rootsList = roots.map(root => ( `- ${root.name || path.basename(root.path)}${root.isDefault ? ' (default)' : ''}: ${root.path}${root.description ? `\n Description: ${root.description}` : ''}` )).join('\n\n'); return { content: [ { type: 'text', text: `Configured Salesforce project roots:\n\n${rootsList}` } ] }; });
- src/sfCommands.ts:192-194 (helper)Helper function that returns a shallow copy of the global projectRoots array used by the sf_list_roots handler.export function getProjectRoots(): ProjectRoot[] { return [...projectRoots]; }
- src/sfCommands.ts:168-173 (schema)TypeScript interface defining the structure of a Salesforce project root, used by sf_list_roots and related functions.interface ProjectRoot { path: string; name?: string; description?: string; isDefault?: boolean; }
- src/index.ts:93-120 (registration)Registration of the sf_list_roots tool on the MCP server, including empty input schema and inline handler.server.tool('sf_list_roots', 'List all configured Salesforce project directories and their metadata', {}, async () => { const roots = getProjectRoots(); if (roots.length === 0) { return { content: [ { type: 'text', text: 'No project roots configured. Use sf_set_project_directory to add a project root.' } ] }; } // Format roots list for display const rootsList = roots.map(root => ( `- ${root.name || path.basename(root.path)}${root.isDefault ? ' (default)' : ''}: ${root.path}${root.description ? `\n Description: ${root.description}` : ''}` )).join('\n\n'); return { content: [ { type: 'text', text: `Configured Salesforce project roots:\n\n${rootsList}` } ] }; });