@salesforce/mcp 0.17.1-dev.0 → 0.17.1
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 +2 -85
- package/lib/modules/platform-cli/index.d.ts +16 -0
- package/lib/modules/platform-cli/index.js +32 -0
- package/lib/{tools/users → modules/platform-cli}/sf-assign-permission-set.d.ts +5 -5
- package/lib/{tools/users → modules/platform-cli}/sf-assign-permission-set.js +1 -1
- package/lib/{tools/orgs → modules/platform-cli}/sf-create-org-snapshot.d.ts +2 -2
- package/lib/{tools/orgs → modules/platform-cli}/sf-create-org-snapshot.js +1 -1
- package/lib/{tools/orgs → modules/platform-cli}/sf-create-scratch-org.d.ts +5 -5
- package/lib/{tools/orgs → modules/platform-cli}/sf-create-scratch-org.js +1 -1
- package/lib/{tools/orgs → modules/platform-cli}/sf-delete-org.d.ts +3 -3
- package/lib/{tools/orgs → modules/platform-cli}/sf-delete-org.js +1 -1
- package/lib/{tools/metadata → modules/platform-cli}/sf-deploy-metadata.d.ts +3 -3
- package/lib/{tools/metadata → modules/platform-cli}/sf-deploy-metadata.js +1 -1
- package/lib/modules/platform-cli/sf-enable-tools.d.ts +2 -0
- package/lib/{tools/dynamic → modules/platform-cli}/sf-enable-tools.js +3 -3
- package/lib/{tools/core → modules/platform-cli}/sf-get-username.d.ts +2 -2
- package/lib/{tools/core → modules/platform-cli}/sf-get-username.js +1 -1
- package/lib/{tools/orgs → modules/platform-cli}/sf-list-all-orgs.d.ts +1 -1
- package/lib/{tools/orgs → modules/platform-cli}/sf-list-all-orgs.js +1 -1
- package/lib/modules/platform-cli/sf-list-tools.d.ts +2 -0
- package/lib/{tools/dynamic → modules/platform-cli}/sf-list-tools.js +2 -2
- package/lib/{tools/orgs → modules/platform-cli}/sf-org-open.d.ts +3 -3
- package/lib/{tools/orgs → modules/platform-cli}/sf-org-open.js +1 -1
- package/lib/{tools/data → modules/platform-cli}/sf-query-org.d.ts +3 -3
- package/lib/{tools/data → modules/platform-cli}/sf-query-org.js +1 -1
- package/lib/{tools/core → modules/platform-cli}/sf-resume.d.ts +3 -3
- package/lib/{tools/core → modules/platform-cli}/sf-resume.js +1 -1
- package/lib/modules/platform-cli/sf-retrieve-metadata.d.ts +2 -0
- package/lib/{tools/metadata → modules/platform-cli}/sf-retrieve-metadata.js +1 -1
- package/lib/{tools/core → modules/platform-cli}/sf-suggest-cli-command.d.ts +1 -1
- package/lib/{tools/core → modules/platform-cli}/sf-suggest-cli-command.js +1 -1
- package/lib/{tools/testing → modules/platform-cli}/sf-test-agents.d.ts +3 -3
- package/lib/{tools/testing → modules/platform-cli}/sf-test-agents.js +1 -1
- package/lib/{tools/testing → modules/platform-cli}/sf-test-apex.d.ts +3 -3
- package/lib/{tools/testing → modules/platform-cli}/sf-test-apex.js +1 -1
- package/lib/modules/platform-cli/utils/tools.d.ts +41 -0
- package/lib/{shared → modules/platform-cli/utils}/tools.js +1 -70
- package/lib/{shared/tools.d.ts → registry.d.ts} +2 -41
- package/lib/registry.js +130 -0
- package/lib/sf-mcp-server.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -3
- package/lib/tools/core/index.d.ts +0 -3
- package/lib/tools/core/index.js +0 -19
- package/lib/tools/data/index.d.ts +0 -1
- package/lib/tools/data/index.js +0 -17
- package/lib/tools/dynamic/index.d.ts +0 -2
- package/lib/tools/dynamic/index.js +0 -18
- package/lib/tools/dynamic/sf-enable-tools.d.ts +0 -2
- package/lib/tools/dynamic/sf-list-tools.d.ts +0 -2
- package/lib/tools/metadata/index.d.ts +0 -2
- package/lib/tools/metadata/index.js +0 -18
- package/lib/tools/metadata/sf-retrieve-metadata.d.ts +0 -2
- package/lib/tools/orgs/index.d.ts +0 -5
- package/lib/tools/orgs/index.js +0 -21
- package/lib/tools/testing/index.d.ts +0 -2
- package/lib/tools/testing/index.js +0 -18
- package/lib/tools/users/index.d.ts +0 -1
- package/lib/tools/users/index.js +0 -17
- package/npm-shrinkwrap.json +0 -18827
|
@@ -13,76 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import Cache from '
|
|
17
|
-
export const TOOLSETS = ['orgs', 'data', 'users', 'metadata', 'testing', 'experimental'];
|
|
18
|
-
/*
|
|
19
|
-
* These are tools that are always enabled at startup. They cannot be disabled and they cannot be dynamically enabled.
|
|
20
|
-
*/
|
|
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
|
-
];
|
|
28
|
-
/**
|
|
29
|
-
* Determines which toolsets should be enabled based on the provided toolsets array and dynamic tools flag.
|
|
30
|
-
*
|
|
31
|
-
* @param {Array<Toolset | 'all'>} toolsets - Array of toolsets to enable. Can include 'all' to enable all non-experimental toolsets.
|
|
32
|
-
* @param {boolean} dynamicTools - Flag indicating whether dynamic tools should be enabled. When true, only core and dynamic toolsets are enabled.
|
|
33
|
-
* @returns {Record<Toolset | 'dynamic' | 'core', boolean>} Object mapping each toolset to a boolean indicating whether it should be enabled.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* // Enable all toolsets except experimental
|
|
37
|
-
* determineToolsetsToEnable(['all'], false)
|
|
38
|
-
* // Returns: { core: true, data: true, dynamic: false, experimental: false, metadata: true, orgs: true, testing: true, users: true }
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* // Enable only dynamic tools
|
|
42
|
-
* determineToolsetsToEnable([], true)
|
|
43
|
-
* // Returns: { core: true, data: false, dynamic: true, experimental: false, metadata: false, orgs: false, testing: false, users: false }
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* // Enable specific toolsets
|
|
47
|
-
* determineToolsetsToEnable(['data', 'users'], false)
|
|
48
|
-
* // Returns: { core: true, data: true, dynamic: false, experimental: false, metadata: false, orgs: false, testing: false, users: true }
|
|
49
|
-
*/
|
|
50
|
-
export function determineToolsetsToEnable(toolsets, dynamicTools) {
|
|
51
|
-
if (dynamicTools) {
|
|
52
|
-
return {
|
|
53
|
-
core: true,
|
|
54
|
-
data: true,
|
|
55
|
-
dynamic: true,
|
|
56
|
-
experimental: false,
|
|
57
|
-
metadata: true,
|
|
58
|
-
orgs: true,
|
|
59
|
-
testing: true,
|
|
60
|
-
users: true,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (toolsets.includes('all')) {
|
|
64
|
-
return {
|
|
65
|
-
core: true,
|
|
66
|
-
data: true,
|
|
67
|
-
dynamic: false,
|
|
68
|
-
experimental: false,
|
|
69
|
-
metadata: true,
|
|
70
|
-
orgs: true,
|
|
71
|
-
testing: true,
|
|
72
|
-
users: true,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
core: true,
|
|
77
|
-
data: toolsets.includes('data'),
|
|
78
|
-
dynamic: false,
|
|
79
|
-
experimental: toolsets.includes('experimental'),
|
|
80
|
-
metadata: toolsets.includes('metadata'),
|
|
81
|
-
orgs: toolsets.includes('orgs'),
|
|
82
|
-
testing: toolsets.includes('testing'),
|
|
83
|
-
users: toolsets.includes('users'),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
16
|
+
import Cache from '../../../shared/cache.js';
|
|
86
17
|
/**
|
|
87
18
|
* Add a tool to the cache
|
|
88
19
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SfMcpServer } from './sf-mcp-server.js';
|
|
2
2
|
export declare const TOOLSETS: readonly ["orgs", "data", "users", "metadata", "testing", "experimental"];
|
|
3
3
|
type Toolset = (typeof TOOLSETS)[number];
|
|
4
4
|
export declare const CORE_TOOLS: string[];
|
|
@@ -25,44 +25,5 @@ export declare const CORE_TOOLS: string[];
|
|
|
25
25
|
* // Returns: { core: true, data: true, dynamic: false, experimental: false, metadata: false, orgs: false, testing: false, users: true }
|
|
26
26
|
*/
|
|
27
27
|
export declare function determineToolsetsToEnable(toolsets: Array<Toolset | 'all'>, dynamicTools: boolean): Record<Toolset | 'dynamic' | 'core', boolean>;
|
|
28
|
-
|
|
29
|
-
* Add a tool to the cache
|
|
30
|
-
*/
|
|
31
|
-
export declare function addTool(tool: RegisteredTool, name: string): Promise<{
|
|
32
|
-
success: boolean;
|
|
33
|
-
message: string;
|
|
34
|
-
}>;
|
|
35
|
-
/**
|
|
36
|
-
* Enable an individual tool
|
|
37
|
-
*/
|
|
38
|
-
export declare function enableTool(toolName: string): Promise<{
|
|
39
|
-
success: boolean;
|
|
40
|
-
message: string;
|
|
41
|
-
}>;
|
|
42
|
-
export declare function enableTools(tools: string[]): Promise<Array<{
|
|
43
|
-
success: boolean;
|
|
44
|
-
message: string;
|
|
45
|
-
}>>;
|
|
46
|
-
/**
|
|
47
|
-
* Disable an individual tool
|
|
48
|
-
*/
|
|
49
|
-
export declare function disableTool(toolName: string): Promise<{
|
|
50
|
-
success: boolean;
|
|
51
|
-
message: string;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* Get individual tool status
|
|
55
|
-
*/
|
|
56
|
-
export declare function getToolStatus(toolName: string): Promise<{
|
|
57
|
-
enabled: boolean;
|
|
58
|
-
description: string;
|
|
59
|
-
} | undefined>;
|
|
60
|
-
/**
|
|
61
|
-
* List all individual tools with their status
|
|
62
|
-
*/
|
|
63
|
-
export declare function listAllTools(): Promise<Array<{
|
|
64
|
-
name: string;
|
|
65
|
-
enabled: boolean;
|
|
66
|
-
description: string;
|
|
67
|
-
}>>;
|
|
28
|
+
export declare function registerToolsets(toolsets: Array<Toolset | 'all'>, dynamicTools: boolean, server: SfMcpServer): void;
|
|
68
29
|
export {};
|
package/lib/registry.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ux } from '@oclif/core';
|
|
17
|
+
import * as platformCli from './modules/platform-cli/index.js';
|
|
18
|
+
export const TOOLSETS = ['orgs', 'data', 'users', 'metadata', 'testing', 'experimental'];
|
|
19
|
+
/*
|
|
20
|
+
* These are tools that are always enabled at startup. They cannot be disabled and they cannot be dynamically enabled.
|
|
21
|
+
*
|
|
22
|
+
* If you are added a new core tool, please add it to this list so that the SfMcpServer knows about it.
|
|
23
|
+
*/
|
|
24
|
+
export const CORE_TOOLS = [
|
|
25
|
+
'sf-get-username',
|
|
26
|
+
'sf-resume',
|
|
27
|
+
'sf-enable-tools',
|
|
28
|
+
'sf-list-tools',
|
|
29
|
+
'sf-suggest-cli-command',
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* The tool registry maps toolsets to functions that register tools with the server.
|
|
33
|
+
*
|
|
34
|
+
* When adding a new tool, you must add it to the appropriate toolset in this registry.
|
|
35
|
+
*/
|
|
36
|
+
const TOOL_REGISTRY = {
|
|
37
|
+
core: [platformCli.getUsername, platformCli.resume, platformCli.suggestCliCommand],
|
|
38
|
+
dynamic: [platformCli.enableTools, platformCli.listTools],
|
|
39
|
+
orgs: [platformCli.listAllOrgs],
|
|
40
|
+
data: [platformCli.queryOrg],
|
|
41
|
+
users: [platformCli.assignPermissionSet],
|
|
42
|
+
testing: [platformCli.testAgent, platformCli.testApex],
|
|
43
|
+
metadata: [platformCli.deployMetadata, platformCli.retrieveMetadata],
|
|
44
|
+
experimental: [
|
|
45
|
+
platformCli.orgOpen,
|
|
46
|
+
platformCli.createScratchOrg,
|
|
47
|
+
platformCli.deleteOrg,
|
|
48
|
+
platformCli.createOrgSnapshot,
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Determines which toolsets should be enabled based on the provided toolsets array and dynamic tools flag.
|
|
53
|
+
*
|
|
54
|
+
* @param {Array<Toolset | 'all'>} toolsets - Array of toolsets to enable. Can include 'all' to enable all non-experimental toolsets.
|
|
55
|
+
* @param {boolean} dynamicTools - Flag indicating whether dynamic tools should be enabled. When true, only core and dynamic toolsets are enabled.
|
|
56
|
+
* @returns {Record<Toolset | 'dynamic' | 'core', boolean>} Object mapping each toolset to a boolean indicating whether it should be enabled.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Enable all toolsets except experimental
|
|
60
|
+
* determineToolsetsToEnable(['all'], false)
|
|
61
|
+
* // Returns: { core: true, data: true, dynamic: false, experimental: false, metadata: true, orgs: true, testing: true, users: true }
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Enable only dynamic tools
|
|
65
|
+
* determineToolsetsToEnable([], true)
|
|
66
|
+
* // Returns: { core: true, data: false, dynamic: true, experimental: false, metadata: false, orgs: false, testing: false, users: false }
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Enable specific toolsets
|
|
70
|
+
* determineToolsetsToEnable(['data', 'users'], false)
|
|
71
|
+
* // Returns: { core: true, data: true, dynamic: false, experimental: false, metadata: false, orgs: false, testing: false, users: true }
|
|
72
|
+
*/
|
|
73
|
+
export function determineToolsetsToEnable(toolsets, dynamicTools) {
|
|
74
|
+
if (dynamicTools) {
|
|
75
|
+
return {
|
|
76
|
+
core: true,
|
|
77
|
+
data: true,
|
|
78
|
+
dynamic: true,
|
|
79
|
+
experimental: false,
|
|
80
|
+
metadata: true,
|
|
81
|
+
orgs: true,
|
|
82
|
+
testing: true,
|
|
83
|
+
users: true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (toolsets.includes('all')) {
|
|
87
|
+
return {
|
|
88
|
+
core: true,
|
|
89
|
+
data: true,
|
|
90
|
+
dynamic: false,
|
|
91
|
+
experimental: false,
|
|
92
|
+
metadata: true,
|
|
93
|
+
orgs: true,
|
|
94
|
+
testing: true,
|
|
95
|
+
users: true,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
core: true,
|
|
100
|
+
data: toolsets.includes('data'),
|
|
101
|
+
dynamic: false,
|
|
102
|
+
experimental: toolsets.includes('experimental'),
|
|
103
|
+
metadata: toolsets.includes('metadata'),
|
|
104
|
+
orgs: toolsets.includes('orgs'),
|
|
105
|
+
testing: toolsets.includes('testing'),
|
|
106
|
+
users: toolsets.includes('users'),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function registerToolset(toolset, server) {
|
|
110
|
+
if (TOOL_REGISTRY[toolset]) {
|
|
111
|
+
for (const tool of TOOL_REGISTRY[toolset]) {
|
|
112
|
+
tool(server);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
throw new Error(`Failed to register toolset ${toolset}.`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export function registerToolsets(toolsets, dynamicTools, server) {
|
|
120
|
+
const toolsetsToEnable = determineToolsetsToEnable(toolsets, dynamicTools);
|
|
121
|
+
for (const toolset of ['core', 'dynamic', ...TOOLSETS]) {
|
|
122
|
+
if (!toolsetsToEnable[toolset]) {
|
|
123
|
+
ux.stderr(`Skipping registration of ${toolset} tools`);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
ux.stderr(`Registering ${toolset} tools`);
|
|
127
|
+
registerToolset(toolset, server);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=registry.js.map
|
package/lib/sf-mcp-server.js
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
17
17
|
import { Logger } from '@salesforce/core';
|
|
18
|
-
import { addTool
|
|
18
|
+
import { addTool } from './modules/platform-cli/utils/tools.js';
|
|
19
19
|
import { createRateLimiter } from './shared/rate-limiter.js';
|
|
20
|
+
import { CORE_TOOLS } from './registry.js';
|
|
20
21
|
/**
|
|
21
22
|
* A server implementation that extends the base MCP server with telemetry and rate limiting capabilities.
|
|
22
23
|
*
|