@salesforce/mcp 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -158,7 +158,7 @@ You can also use special values to control access to orgs:
158
158
  if (toolsetsToEnable.dynamic) {
159
159
  this.logToStderr('Registering dynamic tools');
160
160
  // Individual tool management
161
- dynamic.registerToolEnableTool(server);
161
+ dynamic.registerToolEnableTools(server);
162
162
  dynamic.registerToolListTools(server);
163
163
  }
164
164
  // ************************
@@ -39,6 +39,10 @@ export declare function enableTool(toolName: string): Promise<{
39
39
  success: boolean;
40
40
  message: string;
41
41
  }>;
42
+ export declare function enableTools(tools: string[]): Promise<Array<{
43
+ success: boolean;
44
+ message: string;
45
+ }>>;
42
46
  /**
43
47
  * Disable an individual tool
44
48
  */
@@ -18,7 +18,13 @@ export const TOOLSETS = ['orgs', 'data', 'users', 'metadata', 'testing', 'experi
18
18
  /*
19
19
  * These are tools that are always enabled at startup. They cannot be disabled and they cannot be dynamically enabled.
20
20
  */
21
- export const CORE_TOOLS = ['sf-get-username', 'sf-resume', 'sf-enable-tool', 'sf-list-tools', 'sf-suggest-cli-command'];
21
+ export const CORE_TOOLS = [
22
+ 'sf-get-username',
23
+ 'sf-resume',
24
+ 'sf-enable-tools',
25
+ 'sf-list-tools',
26
+ 'sf-suggest-cli-command',
27
+ ];
22
28
  /**
23
29
  * Determines which toolsets should be enabled based on the provided toolsets array and dynamic tools flag.
24
30
  *
@@ -112,6 +118,25 @@ export async function enableTool(toolName) {
112
118
  toolInfo.tool.enable();
113
119
  return { success: true, message: `Tool ${toolName} enabled` };
114
120
  }
121
+ export async function enableTools(tools) {
122
+ const results = [];
123
+ const cachedTools = await Cache.safeGet('tools');
124
+ for (const tool of tools) {
125
+ const toolInfo = cachedTools.find((t) => t.name === tool);
126
+ if (!toolInfo) {
127
+ results.push({ success: false, message: `Tool ${tool} not found` });
128
+ continue;
129
+ }
130
+ if (toolInfo.tool.enabled) {
131
+ results.push({ success: false, message: `Tool ${tool} is already enabled` });
132
+ continue;
133
+ }
134
+ // Enable the tool directly
135
+ toolInfo.tool.enable();
136
+ results.push({ success: true, message: `Tool ${tool} enabled` });
137
+ }
138
+ return results;
139
+ }
115
140
  /**
116
141
  * Disable an individual tool
117
142
  */
@@ -23,7 +23,18 @@ const suggestCliCommandParamsSchema = z.object({
23
23
  * Suggest a Salesforce CLI (sf) command based on user input.
24
24
  */
25
25
  export const registerToolSuggestCliCommand = (server) => {
26
- server.tool('sf-suggest-cli-command', "Suggests an `sf` CLI command based on a natural language query. It finds relevant commands from a local index and uses an LLM to construct the final, precise command to fulfill the user's request. Use this tool whenever a user asks for guidance on how to use the Salesforce CLI (`sf` or `sfdx`), needs help with command syntax, wants to know what command to run for a specific task, or asks questions like 'how do I...', 'what command...', or 'how to...' related to Salesforce development operations.", suggestCliCommandParamsSchema.shape, {
26
+ server.tool('sf-suggest-cli-command', `Suggests an \`sf\` CLI command based on a natural language query. It finds relevant commands from a local index and uses an LLM to construct the final, precise command to fulfill the user's request.
27
+
28
+ AGENT INSTRUCTIONS:
29
+ Use this tool whenever a user:
30
+ - asks for guidance on how to use the Salesforce CLI (sf or sfdx)
31
+ - needs help with Salesforce CLI (sf or sfdx) command syntax
32
+ - wants to know what Salesforce CLI (sf or sfdx) command to run for a specific task
33
+ - asks questions like 'how do I...', 'what command...', or 'how to...' related to Salesforce development operations.
34
+ NEVER use this tool for enabling Salesforce MCP tools (use sf-enable-tools instead).
35
+ NEVER use this tool for listing available Salesforce MCP tools (use sf-list-tools instead).
36
+ NEVER use this tool for understanding the Salesforce MCP server's capabilities.
37
+ NEVER use this tool for understanding the input schema of a Salesforce MCP tool.`, suggestCliCommandParamsSchema.shape, {
27
38
  readOnlyHint: true,
28
39
  }, async ({ query }) => {
29
40
  const assets = await getAssets();
@@ -1,2 +1,2 @@
1
- export { registerToolEnableTool } from './sf-enable-tool.js';
1
+ export { registerToolEnableTools } from './sf-enable-tools.js';
2
2
  export { registerToolListTools } from './sf-list-tools.js';
@@ -13,6 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { registerToolEnableTool } from './sf-enable-tool.js';
16
+ export { registerToolEnableTools } from './sf-enable-tools.js';
17
17
  export { registerToolListTools } from './sf-list-tools.js';
18
18
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import { SfMcpServer } from '../../sf-mcp-server.js';
2
+ export declare function registerToolEnableTools(server: SfMcpServer): void;
@@ -15,25 +15,28 @@
15
15
  */
16
16
  import { z } from 'zod';
17
17
  import { textResponse } from '../../shared/utils.js';
18
- import { enableTool } from '../../shared/tools.js';
19
- const enableToolParamsSchema = z.object({
20
- tool: z.string().describe('The name of the tool to enable'),
18
+ import { enableTools } from '../../shared/tools.js';
19
+ const enableToolsParamsSchema = z.object({
20
+ tools: z.array(z.string()).describe('The names of the tools to enable'),
21
21
  });
22
- export function registerToolEnableTool(server) {
23
- server.tool('sf-enable-tool', `Enable one of the tools the Salesforce MCP server provides.
22
+ export function registerToolEnableTools(server) {
23
+ server.tool('sf-enable-tools', `Enable one or more of the tools the Salesforce MCP server provides.
24
24
 
25
25
  AGENT INSTRUCTIONS:
26
26
  Use sf-list-all-tools first to learn what tools are available for enabling.
27
- Once you have enabled the tool, you MUST invoke that tool to accomplish the user's original request - DO NOT USE A DIFFERENT TOOL OR THE COMMAND LINE.`, enableToolParamsSchema.shape, {
28
- title: 'Enable an individual tool',
27
+ Once you have enabled the tool, you MUST invoke that tool to accomplish the user's original request - DO NOT USE A DIFFERENT TOOL OR THE COMMAND LINE.`, enableToolsParamsSchema.shape, {
28
+ title: 'Enable Salesforce MCP tools',
29
29
  readOnlyHint: true,
30
30
  openWorldHint: false,
31
- }, async ({ tool }) => {
32
- const result = await enableTool(tool);
33
- if (result.success) {
34
- server.sendToolListChanged();
31
+ }, async ({ tools }) => {
32
+ if (tools.length === 0) {
33
+ return textResponse('No tools specified to enable.', true);
35
34
  }
36
- return textResponse(result.message, !result.success);
35
+ const results = await enableTools(tools);
36
+ server.sendToolListChanged();
37
+ const hasError = results.some((result) => !result.success);
38
+ const resultMessages = results.map((result) => result.message).join('\n');
39
+ return textResponse(resultMessages, hasError);
37
40
  });
38
41
  }
39
- //# sourceMappingURL=sf-enable-tool.js.map
42
+ //# sourceMappingURL=sf-enable-tools.js.map
@@ -25,8 +25,8 @@ ONLY use this tool if:
25
25
  2. You genuinely don't know what tools are available for a specific task
26
26
  3. You need to discover new tools for an unfamiliar use case
27
27
 
28
- If you find a tool you want to enable, call sf-enable-tool with the tool name.
29
- Once you have enabled the tool, you MUST invoke that tool to accomplish the user's original request - DO NOT USE A DIFFERENT TOOL OR THE COMMAND LINE.
28
+ If you find one or more tools you want to enable, call sf-enable-tools with all the tool names.
29
+ Once you have enabled a tool, you MUST invoke the tool to accomplish the user's original request - DO NOT USE A DIFFERENT TOOL OR THE COMMAND LINE.
30
30
  Once a tool has been enabled, you do not need to call sf-list-tools again - instead, invoke the desired tool directly.`, {
31
31
  title: 'List all individual tools',
32
32
  readOnlyHint: true,