@salesforce/mcp 0.19.2-dev.1 → 0.20.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 +10 -1
- package/lib/registry.js +6 -0
- package/lib/services.d.ts +3 -1
- package/lib/services.js +3 -0
- package/lib/utils/registry-utils.js +8 -2
- package/lib/utils/tools.d.ts +7 -0
- package/lib/utils/tools.js +11 -4
- package/package.json +7 -6
- package/npm-shrinkwrap.json +0 -21503
package/lib/index.js
CHANGED
|
@@ -139,7 +139,16 @@ You can also use special values to control access to orgs:
|
|
|
139
139
|
}, {
|
|
140
140
|
telemetry: this.telemetry,
|
|
141
141
|
});
|
|
142
|
-
const services = new Services({
|
|
142
|
+
const services = new Services({
|
|
143
|
+
telemetry: this.telemetry,
|
|
144
|
+
dataDir: this.config.dataDir,
|
|
145
|
+
// Startup flags that could be useful to reference inside of a MCP tool
|
|
146
|
+
startupFlags: {
|
|
147
|
+
// !! Never pass the 'orgs' flag here. Use 'getOrgService()'.
|
|
148
|
+
'allow-non-ga-tools': flags['allow-non-ga-tools'],
|
|
149
|
+
debug: flags.debug,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
143
152
|
await registerToolsets(flags.toolsets ?? ['all'], flags['dynamic-tools'] ?? false, flags['allow-non-ga-tools'] ?? false, server, services);
|
|
144
153
|
const transport = new StdioServerTransport();
|
|
145
154
|
await server.connect(transport);
|
package/lib/registry.js
CHANGED
|
@@ -15,10 +15,16 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { DxCoreMcpProvider } from '@salesforce/mcp-provider-dx-core';
|
|
17
17
|
import { CodeAnalyzerMcpProvider } from '@salesforce/mcp-provider-code-analyzer';
|
|
18
|
+
import { LwcExpertsMcpProvider } from '@salesforce/mcp-provider-lwc-experts';
|
|
19
|
+
import { AuraExpertsMcpProvider } from '@salesforce/mcp-provider-aura-experts';
|
|
20
|
+
import { MobileWebMcpProvider } from '@salesforce/mcp-provider-mobile-web';
|
|
18
21
|
/** -------- ADD McpProvider INSTANCES HERE ------------------------------------------------------------------------- */
|
|
19
22
|
export const MCP_PROVIDER_REGISTRY = [
|
|
20
23
|
new DxCoreMcpProvider(),
|
|
21
24
|
new CodeAnalyzerMcpProvider(),
|
|
25
|
+
new LwcExpertsMcpProvider(),
|
|
26
|
+
new AuraExpertsMcpProvider(),
|
|
27
|
+
new MobileWebMcpProvider(),
|
|
22
28
|
// Add new instances here
|
|
23
29
|
];
|
|
24
30
|
//# sourceMappingURL=registry.js.map
|
package/lib/services.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Services as IServices, TelemetryService, OrgService, ConfigService } from '@salesforce/mcp-provider-api';
|
|
1
|
+
import { Services as IServices, TelemetryService, OrgService, ConfigService, StartupFlags } from '@salesforce/mcp-provider-api';
|
|
2
2
|
export declare class Services implements IServices {
|
|
3
3
|
private readonly telemetry;
|
|
4
4
|
private readonly dataDir;
|
|
5
|
+
private readonly startupFlags;
|
|
5
6
|
constructor(opts: {
|
|
6
7
|
telemetry: TelemetryService | undefined;
|
|
7
8
|
dataDir: string;
|
|
9
|
+
startupFlags: StartupFlags;
|
|
8
10
|
});
|
|
9
11
|
getTelemetryService(): TelemetryService;
|
|
10
12
|
getConfigService(): ConfigService;
|
package/lib/services.js
CHANGED
|
@@ -3,9 +3,11 @@ import { getConnection, getDefaultTargetOrg, getDefaultTargetDevHub, getAllAllow
|
|
|
3
3
|
export class Services {
|
|
4
4
|
telemetry;
|
|
5
5
|
dataDir;
|
|
6
|
+
startupFlags;
|
|
6
7
|
constructor(opts) {
|
|
7
8
|
this.telemetry = opts.telemetry ? opts.telemetry : new NoopTelemetryService();
|
|
8
9
|
this.dataDir = opts.dataDir;
|
|
10
|
+
this.startupFlags = opts.startupFlags;
|
|
9
11
|
}
|
|
10
12
|
getTelemetryService() {
|
|
11
13
|
return this.telemetry;
|
|
@@ -13,6 +15,7 @@ export class Services {
|
|
|
13
15
|
getConfigService() {
|
|
14
16
|
return {
|
|
15
17
|
getDataDir: () => this.dataDir,
|
|
18
|
+
getStartupFlags: () => this.startupFlags,
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
getOrgService() {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { ux } from '@oclif/core';
|
|
17
17
|
import { MCP_PROVIDER_API_VERSION, ReleaseState, Toolset, TOOLSETS, } from '@salesforce/mcp-provider-api';
|
|
18
18
|
import { MCP_PROVIDER_REGISTRY } from '../registry.js';
|
|
19
|
-
import { addTool } from '../utils/tools.js';
|
|
19
|
+
import { addTool, isToolRegistered } from '../utils/tools.js';
|
|
20
20
|
import { createDynamicServerTools } from '../main-server-provider.js';
|
|
21
21
|
export async function registerToolsets(toolsets, useDynamicTools, allowNonGaTools, server, services) {
|
|
22
22
|
if (useDynamicTools) {
|
|
@@ -29,7 +29,8 @@ export async function registerToolsets(toolsets, useDynamicTools, allowNonGaTool
|
|
|
29
29
|
ux.stderr('Skipping registration of dynamic tools.');
|
|
30
30
|
}
|
|
31
31
|
const toolsetsToEnable = toolsets.includes('all')
|
|
32
|
-
? new Set(TOOLSETS)
|
|
32
|
+
? new Set(TOOLSETS)
|
|
33
|
+
: new Set([Toolset.CORE, ...toolsets]);
|
|
33
34
|
const newToolRegistry = await createToolRegistryFromProviders(MCP_PROVIDER_REGISTRY, services);
|
|
34
35
|
for (const toolset of TOOLSETS) {
|
|
35
36
|
if (toolsetsToEnable.has(toolset)) {
|
|
@@ -48,6 +49,11 @@ async function registerTools(tools, server, useDynamicTools, allowNonGaTools) {
|
|
|
48
49
|
ux.stderr(`* Skipping registration of non-ga tool '${tool.getName()}' because the '--allow-non-ga-tools' flag was not set at server startup.`);
|
|
49
50
|
continue;
|
|
50
51
|
}
|
|
52
|
+
// eslint-disable-next-line no-await-in-loop
|
|
53
|
+
if (await isToolRegistered(tool.getName())) {
|
|
54
|
+
ux.stderr(`* Skipping registration of tool '${tool.getName()}' because it is already registered.`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
51
57
|
const registeredTool = server.registerTool(tool.getName(), tool.getConfig(), (...args) => tool.exec(...args));
|
|
52
58
|
const toolsets = tool.getToolsets();
|
|
53
59
|
if (useDynamicTools && !toolsets.includes(Toolset.CORE)) {
|
package/lib/utils/tools.d.ts
CHANGED
|
@@ -6,6 +6,13 @@ export declare function addTool(tool: RegisteredTool, name: string): Promise<{
|
|
|
6
6
|
success: boolean;
|
|
7
7
|
message: string;
|
|
8
8
|
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Check if a tool is registered
|
|
11
|
+
*
|
|
12
|
+
* @param toolName The name of the tool to check
|
|
13
|
+
* @returns True if the tool is registered, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function isToolRegistered(toolName: string): Promise<boolean>;
|
|
9
16
|
/**
|
|
10
17
|
* Enable an individual tool
|
|
11
18
|
*/
|
package/lib/utils/tools.js
CHANGED
|
@@ -18,10 +18,7 @@ import Cache from './cache.js';
|
|
|
18
18
|
* Add a tool to the cache
|
|
19
19
|
*/
|
|
20
20
|
export async function addTool(tool, name) {
|
|
21
|
-
|
|
22
|
-
// Check if tool already exists
|
|
23
|
-
const existingTool = existingTools.find((t) => t.name === name);
|
|
24
|
-
if (existingTool) {
|
|
21
|
+
if (await isToolRegistered(name)) {
|
|
25
22
|
return { success: false, message: `Tool ${name} already exists` };
|
|
26
23
|
}
|
|
27
24
|
await Cache.safeUpdate('tools', (toolsArray) => {
|
|
@@ -33,6 +30,16 @@ export async function addTool(tool, name) {
|
|
|
33
30
|
});
|
|
34
31
|
return { success: true, message: `Added tool ${name}` };
|
|
35
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Check if a tool is registered
|
|
35
|
+
*
|
|
36
|
+
* @param toolName The name of the tool to check
|
|
37
|
+
* @returns True if the tool is registered, false otherwise
|
|
38
|
+
*/
|
|
39
|
+
export async function isToolRegistered(toolName) {
|
|
40
|
+
const existingTools = await Cache.safeGet('tools');
|
|
41
|
+
return existingTools.some((t) => t.name === toolName);
|
|
42
|
+
}
|
|
36
43
|
/**
|
|
37
44
|
* Enable an individual tool
|
|
38
45
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "MCP Server for interacting with Salesforce instances",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sf-mcp-server": "bin/run.js"
|
|
@@ -22,9 +22,8 @@
|
|
|
22
22
|
"lint-fix": "yarn sf-lint --fix",
|
|
23
23
|
"package": "yarn pack",
|
|
24
24
|
"postpack": "sf-clean --ignore-signing-artifacts",
|
|
25
|
-
"prepack": "
|
|
25
|
+
"prepack": "sf-prepack",
|
|
26
26
|
"prepare": "sf-install",
|
|
27
|
-
"prepublishOnly": "npm shrinkwrap",
|
|
28
27
|
"start": "yarn build && npm link && mcp-inspector sf-mcp-server",
|
|
29
28
|
"test": "wireit",
|
|
30
29
|
"test:only": "wireit"
|
|
@@ -40,7 +39,6 @@
|
|
|
40
39
|
"!lib/**/*.map",
|
|
41
40
|
"messages",
|
|
42
41
|
"LICENSE.txt",
|
|
43
|
-
"npm-shrinkwrap.json",
|
|
44
42
|
"package.json"
|
|
45
43
|
],
|
|
46
44
|
"dependencies": {
|
|
@@ -50,9 +48,12 @@
|
|
|
50
48
|
"@salesforce/apex-node": "^8.2.1",
|
|
51
49
|
"@salesforce/core": "^8.18.0",
|
|
52
50
|
"@salesforce/kit": "^3.1.6",
|
|
53
|
-
"@salesforce/mcp-provider-api": "0.2.
|
|
54
|
-
"@salesforce/mcp-provider-dx-core": "0.2.
|
|
51
|
+
"@salesforce/mcp-provider-api": "0.2.2",
|
|
52
|
+
"@salesforce/mcp-provider-dx-core": "0.2.4",
|
|
55
53
|
"@salesforce/mcp-provider-code-analyzer": "0.0.2",
|
|
54
|
+
"@salesforce/mcp-provider-lwc-experts": "0.1.1",
|
|
55
|
+
"@salesforce/mcp-provider-aura-experts": "0.1.1",
|
|
56
|
+
"@salesforce/mcp-provider-mobile-web": "0.0.3",
|
|
56
57
|
"@salesforce/source-deploy-retrieve": "^12.22.0",
|
|
57
58
|
"@salesforce/source-tracking": "^7.4.8",
|
|
58
59
|
"@salesforce/telemetry": "^6.1.0",
|