@salesforce/mcp 0.16.1 → 0.17.1-dev.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/README.md +4 -3
- package/lib/index.js +1 -1
- package/lib/shared/tools.d.ts +4 -0
- package/lib/shared/tools.js +26 -1
- package/lib/tools/core/sf-suggest-cli-command.js +12 -1
- package/lib/tools/dynamic/index.d.ts +1 -1
- package/lib/tools/dynamic/index.js +1 -1
- package/lib/tools/dynamic/sf-enable-tools.d.ts +2 -0
- package/lib/tools/dynamic/{sf-enable-tool.js → sf-enable-tools.js} +16 -13
- package/lib/tools/dynamic/sf-list-tools.js +2 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/npm-shrinkwrap.json +18827 -0
- package/package.json +3 -1
- package/lib/tools/dynamic/sf-enable-tool.d.ts +0 -2
package/README.md
CHANGED
|
@@ -183,9 +183,11 @@ The `--dynamic-tools` flag enables dynamic tool discovery and loading. When this
|
|
|
183
183
|
|
|
184
184
|
#### Core Toolset (always enabled)
|
|
185
185
|
|
|
186
|
-
Includes
|
|
186
|
+
Includes these tools:
|
|
187
187
|
|
|
188
188
|
- `sf-get-username` - Determines the appropriate username or alias for Salesforce operations, handling both default orgs and Dev Hubs.
|
|
189
|
+
- `sf-resume` - Resumes a long-running operation that wasn't completed by another tool.
|
|
190
|
+
- `sf-suggest-cli-command` - Suggests an `sf` Salesforce CLI command based on a natural language query. The tool finds relevant CLI commands from a local index and uses an LLM to construct the precise command to fulfill your request.
|
|
189
191
|
|
|
190
192
|
#### Orgs Toolset
|
|
191
193
|
|
|
@@ -211,14 +213,13 @@ Includes these tools:
|
|
|
211
213
|
|
|
212
214
|
- `sf-deploy-metadata` - Deploys metadata from your DX project to an org.
|
|
213
215
|
- `sf-retrieve-metadata` - Retrieves metadata from your org to your DX project.
|
|
214
|
-
-
|
|
215
216
|
|
|
216
217
|
#### Testing Toolset
|
|
217
218
|
|
|
218
219
|
Includes these tools:
|
|
219
220
|
|
|
220
221
|
- `sf-test-agents` - Executes agent tests in your org.
|
|
221
|
-
- `sf-test-apex` - Executes apex tests in your org
|
|
222
|
+
- `sf-test-apex` - Executes apex tests in your org.
|
|
222
223
|
|
|
223
224
|
## Configure Other Clients to Use the Salesforce DX MCP Server
|
|
224
225
|
|
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.
|
|
161
|
+
dynamic.registerToolEnableTools(server);
|
|
162
162
|
dynamic.registerToolListTools(server);
|
|
163
163
|
}
|
|
164
164
|
// ************************
|
package/lib/shared/tools.d.ts
CHANGED
|
@@ -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
|
*/
|
package/lib/shared/tools.js
CHANGED
|
@@ -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 = [
|
|
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',
|
|
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 {
|
|
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 {
|
|
16
|
+
export { registerToolEnableTools } from './sf-enable-tools.js';
|
|
17
17
|
export { registerToolListTools } from './sf-list-tools.js';
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -15,25 +15,28 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
import { textResponse } from '../../shared/utils.js';
|
|
18
|
-
import {
|
|
19
|
-
const
|
|
20
|
-
|
|
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
|
|
23
|
-
server.tool('sf-enable-
|
|
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.`,
|
|
28
|
-
title: 'Enable
|
|
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 ({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
server.sendToolListChanged();
|
|
31
|
+
}, async ({ tools }) => {
|
|
32
|
+
if (tools.length === 0) {
|
|
33
|
+
return textResponse('No tools specified to enable.', true);
|
|
35
34
|
}
|
|
36
|
-
|
|
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-
|
|
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
|
|
29
|
-
Once you have enabled
|
|
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,
|