@salesforce/mcp 0.17.1 → 0.17.2-dev.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.d.ts +1 -1
- package/lib/index.js +7 -5
- package/lib/main-server-provider.d.ts +7 -0
- package/lib/main-server-provider.js +31 -0
- package/lib/registry.d.ts +3 -29
- package/lib/registry.js +9 -113
- package/lib/scripts/build-index.js +1 -1
- package/lib/services.d.ts +12 -0
- package/lib/services.js +34 -0
- package/lib/sf-mcp-server.d.ts +12 -7
- package/lib/sf-mcp-server.js +6 -21
- package/lib/telemetry.d.ts +2 -1
- package/lib/tools/sf-enable-tools.d.ts +23 -0
- package/lib/tools/sf-enable-tools.js +77 -0
- package/lib/tools/sf-list-tools.d.ts +8 -0
- package/lib/{modules/platform-cli → tools}/sf-list-tools.js +33 -9
- package/lib/tools/sf-suggest-cli-command.d.ts +25 -0
- package/lib/{modules/platform-cli → tools}/sf-suggest-cli-command.js +46 -18
- package/lib/utils/assets.d.ts +21 -0
- package/lib/{assets.js → utils/assets.js} +23 -33
- package/lib/{shared → utils}/auth.d.ts +3 -8
- package/lib/{shared → utils}/auth.js +2 -42
- package/lib/utils/registry-utils.d.ts +4 -0
- package/lib/utils/registry-utils.js +87 -0
- package/lib/{modules/platform-cli/utils → utils}/tools.js +1 -1
- package/lib/utils/types.d.ts +5 -0
- package/package.json +8 -4
- package/README.md +0 -263
- package/lib/assets.d.ts +0 -44
- package/lib/modules/platform-cli/index.d.ts +0 -16
- package/lib/modules/platform-cli/index.js +0 -32
- package/lib/modules/platform-cli/sf-assign-permission-set.d.ts +0 -20
- package/lib/modules/platform-cli/sf-assign-permission-set.js +0 -89
- package/lib/modules/platform-cli/sf-create-org-snapshot.d.ts +0 -23
- package/lib/modules/platform-cli/sf-create-org-snapshot.js +0 -88
- package/lib/modules/platform-cli/sf-create-scratch-org.d.ts +0 -50
- package/lib/modules/platform-cli/sf-create-scratch-org.js +0 -132
- package/lib/modules/platform-cli/sf-delete-org.d.ts +0 -14
- package/lib/modules/platform-cli/sf-delete-org.js +0 -65
- package/lib/modules/platform-cli/sf-deploy-metadata.d.ts +0 -27
- package/lib/modules/platform-cli/sf-deploy-metadata.js +0 -164
- package/lib/modules/platform-cli/sf-enable-tools.d.ts +0 -2
- package/lib/modules/platform-cli/sf-enable-tools.js +0 -42
- package/lib/modules/platform-cli/sf-get-username.d.ts +0 -17
- package/lib/modules/platform-cli/sf-get-username.js +0 -109
- package/lib/modules/platform-cli/sf-list-all-orgs.d.ts +0 -11
- package/lib/modules/platform-cli/sf-list-all-orgs.js +0 -59
- package/lib/modules/platform-cli/sf-list-tools.d.ts +0 -2
- package/lib/modules/platform-cli/sf-org-open.d.ts +0 -17
- package/lib/modules/platform-cli/sf-org-open.js +0 -57
- package/lib/modules/platform-cli/sf-query-org.d.ts +0 -20
- package/lib/modules/platform-cli/sf-query-org.js +0 -66
- package/lib/modules/platform-cli/sf-resume.d.ts +0 -20
- package/lib/modules/platform-cli/sf-resume.js +0 -149
- package/lib/modules/platform-cli/sf-retrieve-metadata.d.ts +0 -2
- package/lib/modules/platform-cli/sf-retrieve-metadata.js +0 -128
- package/lib/modules/platform-cli/sf-suggest-cli-command.d.ts +0 -5
- package/lib/modules/platform-cli/sf-test-agents.d.ts +0 -21
- package/lib/modules/platform-cli/sf-test-agents.js +0 -84
- package/lib/modules/platform-cli/sf-test-apex.d.ts +0 -40
- package/lib/modules/platform-cli/sf-test-apex.js +0 -132
- package/lib/shared/params.d.ts +0 -5
- package/lib/shared/params.js +0 -46
- package/lib/shared/types.d.ts +0 -33
- package/lib/shared/utils.d.ts +0 -11
- package/lib/shared/utils.js +0 -71
- package/lib/tsconfig.tsbuildinfo +0 -1
- /package/lib/{shared → utils}/cache.d.ts +0 -0
- /package/lib/{shared → utils}/cache.js +0 -0
- /package/lib/{shared → utils}/rate-limiter.d.ts +0 -0
- /package/lib/{shared → utils}/rate-limiter.js +0 -0
- /package/lib/{modules/platform-cli/utils → utils}/tools.d.ts +0 -0
- /package/lib/{shared → utils}/types.js +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { SfMcpServer } from '../../sf-mcp-server.js';
|
|
3
|
-
export declare const orgOpenParamsSchema: z.ZodObject<{
|
|
4
|
-
filePath: z.ZodOptional<z.ZodString>;
|
|
5
|
-
usernameOrAlias: z.ZodString;
|
|
6
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
7
|
-
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
usernameOrAlias: string;
|
|
9
|
-
directory: string;
|
|
10
|
-
filePath?: string | undefined;
|
|
11
|
-
}, {
|
|
12
|
-
usernameOrAlias: string;
|
|
13
|
-
directory: string;
|
|
14
|
-
filePath?: string | undefined;
|
|
15
|
-
}>;
|
|
16
|
-
export type OrgOpenParamsSchema = z.infer<typeof orgOpenParamsSchema>;
|
|
17
|
-
export declare const orgOpen: (server: SfMcpServer) => void;
|
|
@@ -1,57 +0,0 @@
|
|
|
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 { z } from 'zod';
|
|
17
|
-
import { Org } from '@salesforce/core';
|
|
18
|
-
import { MetadataResolver } from '@salesforce/source-deploy-retrieve';
|
|
19
|
-
import open from 'open';
|
|
20
|
-
import { textResponse } from '../../shared/utils.js';
|
|
21
|
-
import { directoryParam, usernameOrAliasParam } from '../../shared/params.js';
|
|
22
|
-
export const orgOpenParamsSchema = z.object({
|
|
23
|
-
filePath: z
|
|
24
|
-
.string()
|
|
25
|
-
.optional()
|
|
26
|
-
.describe('File path of the metadata to open. This should be an existent file path in the project.'),
|
|
27
|
-
usernameOrAlias: usernameOrAliasParam,
|
|
28
|
-
directory: directoryParam,
|
|
29
|
-
});
|
|
30
|
-
export const orgOpen = (server) => {
|
|
31
|
-
server.tool('sf-org-open', `Open a Salesforce org in the browser.
|
|
32
|
-
|
|
33
|
-
You can specify a metadata file you want to open.
|
|
34
|
-
`, orgOpenParamsSchema.shape, {
|
|
35
|
-
title: 'Open Org in Browser',
|
|
36
|
-
readOnlyHint: true,
|
|
37
|
-
openWorldHint: false,
|
|
38
|
-
}, async ({ usernameOrAlias, filePath, directory }) => {
|
|
39
|
-
process.chdir(directory);
|
|
40
|
-
const org = await Org.create({
|
|
41
|
-
aliasOrUsername: usernameOrAlias,
|
|
42
|
-
});
|
|
43
|
-
if (filePath) {
|
|
44
|
-
const metadataResolver = new MetadataResolver();
|
|
45
|
-
const components = metadataResolver.getComponentsFromPath(filePath);
|
|
46
|
-
const typeName = components[0]?.type?.name;
|
|
47
|
-
const metadataBuilderUrl = await org.getMetadataUIURL(typeName, filePath);
|
|
48
|
-
await open(metadataBuilderUrl);
|
|
49
|
-
return textResponse(metadataBuilderUrl.includes('FlexiPageList')
|
|
50
|
-
? "Opened the org in your browser. This metadata file doesn't have a builder UI, opened Lightning App Builder instead."
|
|
51
|
-
: 'Opened this metadata in your browser');
|
|
52
|
-
}
|
|
53
|
-
await open(await org.getFrontDoorUrl());
|
|
54
|
-
return textResponse('Opened the org in your browser.');
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
//# sourceMappingURL=sf-org-open.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { SfMcpServer } from '../../sf-mcp-server.js';
|
|
3
|
-
export declare const queryOrgParamsSchema: z.ZodObject<{
|
|
4
|
-
query: z.ZodString;
|
|
5
|
-
usernameOrAlias: z.ZodString;
|
|
6
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
7
|
-
useToolingApi: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
query: string;
|
|
10
|
-
usernameOrAlias: string;
|
|
11
|
-
directory: string;
|
|
12
|
-
useToolingApi?: boolean | undefined;
|
|
13
|
-
}, {
|
|
14
|
-
query: string;
|
|
15
|
-
usernameOrAlias: string;
|
|
16
|
-
directory: string;
|
|
17
|
-
useToolingApi?: boolean | undefined;
|
|
18
|
-
}>;
|
|
19
|
-
export type QueryOrgOptions = z.infer<typeof queryOrgParamsSchema>;
|
|
20
|
-
export declare const queryOrg: (server: SfMcpServer) => void;
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
/*
|
|
17
|
-
* Query Salesforce org
|
|
18
|
-
*
|
|
19
|
-
* Run a SOQL query against a Salesforce org.
|
|
20
|
-
*
|
|
21
|
-
* Parameters:
|
|
22
|
-
* - query: SOQL query to run (required)
|
|
23
|
-
* - usernameOrAlias: username or alias for the Salesforce org to run the query against
|
|
24
|
-
*
|
|
25
|
-
* Returns:
|
|
26
|
-
* - textResponse: SOQL query results
|
|
27
|
-
*/
|
|
28
|
-
import { z } from 'zod';
|
|
29
|
-
import { getConnection } from '../../shared/auth.js';
|
|
30
|
-
import { textResponse } from '../../shared/utils.js';
|
|
31
|
-
import { directoryParam, usernameOrAliasParam, useToolingApiParam } from '../../shared/params.js';
|
|
32
|
-
export const queryOrgParamsSchema = z.object({
|
|
33
|
-
query: z.string().describe('SOQL query to run'),
|
|
34
|
-
usernameOrAlias: usernameOrAliasParam,
|
|
35
|
-
directory: directoryParam,
|
|
36
|
-
useToolingApi: useToolingApiParam,
|
|
37
|
-
});
|
|
38
|
-
export const queryOrg = (server) => {
|
|
39
|
-
server.tool('sf-query-org', 'Run a SOQL query against a Salesforce org.', queryOrgParamsSchema.shape, {
|
|
40
|
-
title: 'Query Org',
|
|
41
|
-
openWorldHint: false,
|
|
42
|
-
readOnlyHint: true,
|
|
43
|
-
}, async ({ query, usernameOrAlias, directory, useToolingApi }) => {
|
|
44
|
-
try {
|
|
45
|
-
if (!usernameOrAlias)
|
|
46
|
-
return textResponse('The usernameOrAlias parameter is required, if the user did not specify one use the #sf-get-username tool', true);
|
|
47
|
-
process.chdir(directory);
|
|
48
|
-
const connection = await getConnection(usernameOrAlias);
|
|
49
|
-
const result = useToolingApi ? await connection.tooling.query(query) : await connection.query(query);
|
|
50
|
-
return textResponse(`SOQL query results:\n\n${JSON.stringify(result, null, 2)}`);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
let errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
54
|
-
if (errorMessage.endsWith('is not supported.')) {
|
|
55
|
-
if (useToolingApi) {
|
|
56
|
-
errorMessage += '\nTry not using the Tooling API for this query.';
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
errorMessage += '\nTry using the Tooling API for this query.';
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return textResponse(`Failed to query org: ${errorMessage}`, true);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=sf-query-org.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
export declare const resumeParamsSchema: z.ZodObject<{
|
|
4
|
-
jobId: z.ZodString;
|
|
5
|
-
wait: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
6
|
-
usernameOrAlias: z.ZodString;
|
|
7
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
usernameOrAlias: string;
|
|
10
|
-
directory: string;
|
|
11
|
-
jobId: string;
|
|
12
|
-
wait: number;
|
|
13
|
-
}, {
|
|
14
|
-
usernameOrAlias: string;
|
|
15
|
-
directory: string;
|
|
16
|
-
jobId: string;
|
|
17
|
-
wait?: number | undefined;
|
|
18
|
-
}>;
|
|
19
|
-
export type ResumeParamsSchema = z.infer<typeof resumeParamsSchema>;
|
|
20
|
-
export declare const resume: (server: McpServer) => void;
|
|
@@ -1,149 +0,0 @@
|
|
|
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 { z } from 'zod';
|
|
17
|
-
import { AgentTester } from '@salesforce/agents';
|
|
18
|
-
import { validateSalesforceId, scratchOrgResume, PollingClient } from '@salesforce/core';
|
|
19
|
-
import { Duration } from '@salesforce/kit';
|
|
20
|
-
import { MetadataApiDeploy } from '@salesforce/source-deploy-retrieve';
|
|
21
|
-
import { textResponse } from '../../shared/utils.js';
|
|
22
|
-
import { directoryParam, usernameOrAliasParam } from '../../shared/params.js';
|
|
23
|
-
import { getConnection } from '../../shared/auth.js';
|
|
24
|
-
const resumableIdPrefixes = new Map([
|
|
25
|
-
['deploy', '0Af'],
|
|
26
|
-
['scratchOrg', '2SR'],
|
|
27
|
-
['agentTest', '4KB'],
|
|
28
|
-
['orgSnapshot', '0Oo'],
|
|
29
|
-
]);
|
|
30
|
-
/*
|
|
31
|
-
* Resume a long running operation that was not completed by another tool.
|
|
32
|
-
*
|
|
33
|
-
* Intelligently determines the appropriate username or alias for Salesforce operations.
|
|
34
|
-
*
|
|
35
|
-
* Parameters:
|
|
36
|
-
* - jobId: The job id of the long running operation to resume (required)
|
|
37
|
-
* - wait: The amount of time to wait for the operation to complete in minutes (optional)
|
|
38
|
-
* - defaultTargetOrg: Force lookup of default target org (optional)
|
|
39
|
-
* - directory: The directory to run this tool from
|
|
40
|
-
*
|
|
41
|
-
* Returns:
|
|
42
|
-
* - textResponse: Username/alias and org configuration
|
|
43
|
-
*/
|
|
44
|
-
export const resumeParamsSchema = z.object({
|
|
45
|
-
jobId: z.string().describe('The job id of the long running operation to resume (required)'),
|
|
46
|
-
wait: z
|
|
47
|
-
.number()
|
|
48
|
-
.optional()
|
|
49
|
-
.default(30)
|
|
50
|
-
.describe('The amount of time to wait for the operation to complete in minutes (optional)'),
|
|
51
|
-
usernameOrAlias: usernameOrAliasParam,
|
|
52
|
-
directory: directoryParam,
|
|
53
|
-
});
|
|
54
|
-
export const resume = (server) => {
|
|
55
|
-
server.tool('sf-resume', `Resume a long running operation that was not completed by another tool.
|
|
56
|
-
|
|
57
|
-
AGENT INSTRUCTIONS:
|
|
58
|
-
Use this tool to resume a long running operation.
|
|
59
|
-
|
|
60
|
-
EXAMPLE USAGE:
|
|
61
|
-
Resume the metadata deploy job 0Af1234567890
|
|
62
|
-
Resume the deployment and wait for 10 minutes
|
|
63
|
-
Resume the deployment to my org
|
|
64
|
-
Resume scratch org creation
|
|
65
|
-
Resume job 2SR1234567890
|
|
66
|
-
Resume agent tests
|
|
67
|
-
Resume org snapshot with ID 0OoKa000000XZAbKAO
|
|
68
|
-
Report on my org snapshot
|
|
69
|
-
`, resumeParamsSchema.shape, {
|
|
70
|
-
title: 'Resume',
|
|
71
|
-
openWorldHint: false,
|
|
72
|
-
}, async ({ jobId, wait, usernameOrAlias, directory }) => {
|
|
73
|
-
if (!jobId) {
|
|
74
|
-
return textResponse('The jobId parameter is required.', true);
|
|
75
|
-
}
|
|
76
|
-
if (!validateSalesforceId(jobId)) {
|
|
77
|
-
return textResponse('The jobId parameter is not a valid Salesforce id.', true);
|
|
78
|
-
}
|
|
79
|
-
if (!usernameOrAlias)
|
|
80
|
-
return textResponse('The usernameOrAlias parameter is required, if the user did not specify one use the #sf-get-username tool', true);
|
|
81
|
-
process.chdir(directory);
|
|
82
|
-
const connection = await getConnection(usernameOrAlias);
|
|
83
|
-
switch (jobId.substring(0, 3)) {
|
|
84
|
-
case resumableIdPrefixes.get('deploy'):
|
|
85
|
-
return resumeDeployment(connection, jobId, wait);
|
|
86
|
-
case resumableIdPrefixes.get('scratchOrg'):
|
|
87
|
-
return resumeScratchOrg(jobId, wait);
|
|
88
|
-
case resumableIdPrefixes.get('agentTest'):
|
|
89
|
-
return resumeAgentTest(connection, jobId, wait);
|
|
90
|
-
case resumableIdPrefixes.get('orgSnapshot'):
|
|
91
|
-
return resumeOrgSnapshot(connection, jobId, wait);
|
|
92
|
-
default:
|
|
93
|
-
return textResponse(`The job id: ${jobId} is not resumeable.`, true);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
async function resumeDeployment(connection, jobId, wait) {
|
|
98
|
-
try {
|
|
99
|
-
const deploy = new MetadataApiDeploy({ usernameOrConnection: connection, id: jobId });
|
|
100
|
-
const result = await deploy.pollStatus({ timeout: Duration.minutes(wait) });
|
|
101
|
-
return textResponse(`Deploy result: ${JSON.stringify(result.response)}`, !result.response.success);
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
return textResponse(`Resumed deployment failed: ${error instanceof Error ? error.message : 'Unknown error'}`, true);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async function resumeOrgSnapshot(connection, jobId, wait) {
|
|
108
|
-
try {
|
|
109
|
-
const poller = await PollingClient.create({
|
|
110
|
-
timeout: Duration.minutes(wait),
|
|
111
|
-
frequency: Duration.seconds(30),
|
|
112
|
-
poll: async () => {
|
|
113
|
-
const queryResult = await connection.singleRecordQuery(`SELECT Status, Id, SnapshotName, Description, ExpirationDate, CreatedDate FROM OrgSnapshot WHERE Id = '${jobId}'`);
|
|
114
|
-
if (queryResult.Status !== 'In Progress') {
|
|
115
|
-
// either done or error
|
|
116
|
-
return { completed: true, payload: queryResult };
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
return { completed: false };
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
const result = await poller.subscribe();
|
|
124
|
-
return textResponse(`Org snapshot: ${JSON.stringify(result)}`);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
return textResponse(`Resumed org snapshot failed: ${error instanceof Error ? error.message : 'Unknown error'}`, true);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async function resumeScratchOrg(jobId, wait) {
|
|
131
|
-
try {
|
|
132
|
-
const result = await scratchOrgResume(jobId, Duration.minutes(wait));
|
|
133
|
-
return textResponse(`Scratch org created: ${JSON.stringify(result)}`, false);
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
return textResponse(`Resumed scratch org creation failed: ${error instanceof Error ? error.message : 'Unknown error'}`, true);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
async function resumeAgentTest(connection, jobId, wait) {
|
|
140
|
-
try {
|
|
141
|
-
const agentTester = new AgentTester(connection);
|
|
142
|
-
const result = await agentTester.poll(jobId, { timeout: Duration.minutes(wait) });
|
|
143
|
-
return textResponse(`Agent test result: ${JSON.stringify(result)}`, !!result.errorMessage);
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
return textResponse(`Resumed agent test failed: ${error instanceof Error ? error.message : 'Unknown error'}`, true);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=sf-resume.js.map
|
|
@@ -1,128 +0,0 @@
|
|
|
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 { z } from 'zod';
|
|
17
|
-
import { Org, SfProject } from '@salesforce/core';
|
|
18
|
-
import { SourceTracking } from '@salesforce/source-tracking';
|
|
19
|
-
import { ComponentSetBuilder } from '@salesforce/source-deploy-retrieve';
|
|
20
|
-
import { ensureString } from '@salesforce/ts-types';
|
|
21
|
-
import { Duration } from '@salesforce/kit';
|
|
22
|
-
import { directoryParam, usernameOrAliasParam } from '../../shared/params.js';
|
|
23
|
-
import { textResponse } from '../../shared/utils.js';
|
|
24
|
-
import { getConnection } from '../../shared/auth.js';
|
|
25
|
-
const retrieveMetadataParams = z.object({
|
|
26
|
-
sourceDir: z
|
|
27
|
-
.array(z.string())
|
|
28
|
-
.describe('Path to the local source files to retrieve. Leave this unset if the user is vague about what to retrieve.')
|
|
29
|
-
.optional(),
|
|
30
|
-
manifest: z.string().describe('Full file path for manifest (XML file) of components to retrieve.').optional(),
|
|
31
|
-
usernameOrAlias: usernameOrAliasParam,
|
|
32
|
-
directory: directoryParam,
|
|
33
|
-
});
|
|
34
|
-
/*
|
|
35
|
-
* Retrieve metadata from an org to your local project.
|
|
36
|
-
*
|
|
37
|
-
* Parameters:
|
|
38
|
-
* - sourceDir: Path to the local source files to retrieve.
|
|
39
|
-
* - manifest: Full file path for manifest (XML file) of components to retrieve.
|
|
40
|
-
* - usernameOrAlias: Username or alias of the Salesforce org to retrieve from.
|
|
41
|
-
* - directory: Directory of the local project.
|
|
42
|
-
*
|
|
43
|
-
* Returns:
|
|
44
|
-
* - textResponse: Retrieve result.
|
|
45
|
-
*/
|
|
46
|
-
export const retrieveMetadata = (server) => {
|
|
47
|
-
server.tool('sf-retrieve-metadata', `Retrieve metadata from an org to your local project.
|
|
48
|
-
|
|
49
|
-
AGENT INSTRUCTIONS:
|
|
50
|
-
If the user doesn't specify what to retrieve exactly ("retrieve my changes"), leave the "sourceDir" and "manifest" params empty so the tool calculates which files to retrieve.
|
|
51
|
-
|
|
52
|
-
EXAMPLE USAGE:
|
|
53
|
-
Retrieve changes
|
|
54
|
-
Retrieve changes from my org
|
|
55
|
-
Retrieve this file from my org
|
|
56
|
-
Retrieve the metadata in the manifest
|
|
57
|
-
Retrieve X metadata from my org
|
|
58
|
-
`, retrieveMetadataParams.shape, {
|
|
59
|
-
title: 'Retrieve Metadata',
|
|
60
|
-
openWorldHint: false,
|
|
61
|
-
destructiveHint: true,
|
|
62
|
-
}, async ({ sourceDir, usernameOrAlias, directory, manifest }) => {
|
|
63
|
-
if (sourceDir && manifest) {
|
|
64
|
-
return textResponse("You can't specify both `sourceDir` and `manifest` parameters.", true);
|
|
65
|
-
}
|
|
66
|
-
if (!usernameOrAlias)
|
|
67
|
-
return textResponse('The usernameOrAlias parameter is required, if the user did not specify one use the #sf-get-username tool', true);
|
|
68
|
-
// needed for org allowlist to work
|
|
69
|
-
process.chdir(directory);
|
|
70
|
-
const connection = await getConnection(usernameOrAlias);
|
|
71
|
-
const project = await SfProject.resolve(directory);
|
|
72
|
-
const org = await Org.create({ connection });
|
|
73
|
-
if (!sourceDir && !manifest && !(await org.tracksSource())) {
|
|
74
|
-
return textResponse('This org does not have source-tracking enabled or does not support source-tracking. You should specify the files or a manifest to retrieve.', true);
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
const stl = await SourceTracking.create({
|
|
78
|
-
org,
|
|
79
|
-
project,
|
|
80
|
-
subscribeSDREvents: true,
|
|
81
|
-
});
|
|
82
|
-
const componentSet = await buildRetrieveComponentSet(connection, project, stl, sourceDir, manifest);
|
|
83
|
-
if (componentSet.size === 0) {
|
|
84
|
-
// STL found no changes
|
|
85
|
-
return textResponse('No remote changes to retrieve were found.');
|
|
86
|
-
}
|
|
87
|
-
const retrieve = await componentSet.retrieve({
|
|
88
|
-
usernameOrConnection: connection,
|
|
89
|
-
merge: true,
|
|
90
|
-
format: 'source',
|
|
91
|
-
output: project.getDefaultPackage().fullPath,
|
|
92
|
-
});
|
|
93
|
-
// polling freq. is set dynamically by SDR based no the component set size.
|
|
94
|
-
const result = await retrieve.pollStatus({
|
|
95
|
-
timeout: Duration.minutes(10),
|
|
96
|
-
});
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
98
|
-
const { zipFile, ...retrieveResult } = result.response;
|
|
99
|
-
return textResponse(`Retrieve result: ${JSON.stringify(retrieveResult)}`, !retrieveResult.success);
|
|
100
|
-
// }
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
return textResponse(`Failed to retrieve metadata: ${error instanceof Error ? error.message : 'Unknown error'}`, true);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
async function buildRetrieveComponentSet(connection, project, stl, sourceDir, manifestPath) {
|
|
108
|
-
if (sourceDir || manifestPath) {
|
|
109
|
-
return ComponentSetBuilder.build({
|
|
110
|
-
apiversion: connection.getApiVersion(),
|
|
111
|
-
sourceapiversion: ensureString((await project.resolveProjectConfig()).sourceApiVersion),
|
|
112
|
-
sourcepath: sourceDir,
|
|
113
|
-
...(manifestPath
|
|
114
|
-
? {
|
|
115
|
-
manifest: {
|
|
116
|
-
manifestPath,
|
|
117
|
-
directoryPaths: project.getUniquePackageDirectories().map((pDir) => pDir.fullPath),
|
|
118
|
-
},
|
|
119
|
-
}
|
|
120
|
-
: {}),
|
|
121
|
-
projectDir: project.getPath(),
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
// No specific metadata requested to retrieve, build component set from STL.
|
|
125
|
-
const cs = await stl.maybeApplyRemoteDeletesToLocal(true);
|
|
126
|
-
return cs.componentSetFromNonDeletes;
|
|
127
|
-
}
|
|
128
|
-
//# sourceMappingURL=sf-retrieve-metadata.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { SfMcpServer } from '../../sf-mcp-server.js';
|
|
3
|
-
declare const runAgentTestsParam: z.ZodObject<{
|
|
4
|
-
agentApiName: z.ZodString;
|
|
5
|
-
usernameOrAlias: z.ZodString;
|
|
6
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
7
|
-
async: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
usernameOrAlias: string;
|
|
10
|
-
directory: string;
|
|
11
|
-
async: boolean;
|
|
12
|
-
agentApiName: string;
|
|
13
|
-
}, {
|
|
14
|
-
usernameOrAlias: string;
|
|
15
|
-
directory: string;
|
|
16
|
-
agentApiName: string;
|
|
17
|
-
async?: boolean | undefined;
|
|
18
|
-
}>;
|
|
19
|
-
export type AgentRunTests = z.infer<typeof runAgentTestsParam>;
|
|
20
|
-
export declare const testAgent: (server: SfMcpServer) => void;
|
|
21
|
-
export {};
|
|
@@ -1,84 +0,0 @@
|
|
|
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 { z } from 'zod';
|
|
17
|
-
import { AgentTester } from '@salesforce/agents';
|
|
18
|
-
import { Duration } from '@salesforce/kit';
|
|
19
|
-
import { directoryParam, usernameOrAliasParam } from '../../shared/params.js';
|
|
20
|
-
import { textResponse } from '../../shared/utils.js';
|
|
21
|
-
import { getConnection } from '../../shared/auth.js';
|
|
22
|
-
const runAgentTestsParam = z.object({
|
|
23
|
-
agentApiName: z.string().describe(`Agent test to run
|
|
24
|
-
if unsure, list all files matching the pattern **/aiEvaluationDefinitions/*.aiEvaluationDefinition-meta.xml
|
|
25
|
-
only one test can be executed at a time
|
|
26
|
-
`),
|
|
27
|
-
usernameOrAlias: usernameOrAliasParam,
|
|
28
|
-
directory: directoryParam,
|
|
29
|
-
async: z
|
|
30
|
-
.boolean()
|
|
31
|
-
.default(false)
|
|
32
|
-
.describe('Whether to wait for the tests to finish (false) or quickly return only the test id (true)'),
|
|
33
|
-
});
|
|
34
|
-
/*
|
|
35
|
-
* Run Agent tests in a Salesforce org.
|
|
36
|
-
*
|
|
37
|
-
* Parameters:
|
|
38
|
-
* - agentApiName: this will be the aiEvaluationDefinition's name
|
|
39
|
-
* - usernameOrAlias: Username or alias of the Salesforce org to run tests in.
|
|
40
|
-
* - directory: Directory of the local project.
|
|
41
|
-
*
|
|
42
|
-
* Returns:
|
|
43
|
-
* - textResponse: Test result.
|
|
44
|
-
*/
|
|
45
|
-
export const testAgent = (server) => {
|
|
46
|
-
server.tool('sf-test-agents', `Run Agent tests in an org.
|
|
47
|
-
|
|
48
|
-
AGENT INSTRUCTIONS:
|
|
49
|
-
If the user doesn't specify what to test, take context from the currently open file
|
|
50
|
-
This will ONLY run Agent tests, NOT apex tests, lightning tests, flow tests, or any other type of test.
|
|
51
|
-
|
|
52
|
-
this should be chosen when a file in the 'aiEvaluationDefinitions' directory is mentioned
|
|
53
|
-
|
|
54
|
-
EXAMPLE USAGE:
|
|
55
|
-
Run tests for the X agent
|
|
56
|
-
Run this test
|
|
57
|
-
start myAgentTest and don't wait for results
|
|
58
|
-
`, runAgentTestsParam.shape, {
|
|
59
|
-
title: 'Run Agent Tests',
|
|
60
|
-
openWorldHint: false,
|
|
61
|
-
}, async ({ usernameOrAlias, agentApiName, directory, async }) => {
|
|
62
|
-
if (!usernameOrAlias)
|
|
63
|
-
return textResponse('The usernameOrAlias parameter is required, if the user did not specify one use the #sf-get-username tool', true);
|
|
64
|
-
// needed for org allowlist to work
|
|
65
|
-
process.chdir(directory);
|
|
66
|
-
const connection = await getConnection(usernameOrAlias);
|
|
67
|
-
try {
|
|
68
|
-
const agentTester = new AgentTester(connection);
|
|
69
|
-
if (async) {
|
|
70
|
-
const startResult = await agentTester.start(agentApiName);
|
|
71
|
-
return textResponse(`Test Run: ${JSON.stringify(startResult)}`);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
const test = await agentTester.start(agentApiName);
|
|
75
|
-
const result = await agentTester.poll(test.runId, { timeout: Duration.minutes(10) });
|
|
76
|
-
return textResponse(`Test result: ${JSON.stringify(result)}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
return textResponse(`Failed to run Agent Tests: ${e instanceof Error ? e.message : 'Unknown error'}`, true);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=sf-test-agents.js.map
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { TestLevel } from '@salesforce/apex-node';
|
|
3
|
-
import { SfMcpServer } from '../../sf-mcp-server.js';
|
|
4
|
-
declare const runApexTestsParam: z.ZodObject<{
|
|
5
|
-
testLevel: z.ZodEnum<[TestLevel.RunLocalTests, TestLevel.RunAllTestsInOrg, TestLevel.RunSpecifiedTests]>;
|
|
6
|
-
classNames: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
7
|
-
methodNames: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
-
async: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
-
suiteName: z.ZodOptional<z.ZodString>;
|
|
10
|
-
testRunId: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
11
|
-
verbose: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
-
codeCoverage: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
-
usernameOrAlias: z.ZodString;
|
|
14
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
15
|
-
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
codeCoverage: boolean;
|
|
17
|
-
testLevel: TestLevel;
|
|
18
|
-
usernameOrAlias: string;
|
|
19
|
-
directory: string;
|
|
20
|
-
async: boolean;
|
|
21
|
-
verbose: boolean;
|
|
22
|
-
classNames?: string[] | undefined;
|
|
23
|
-
methodNames?: string[] | undefined;
|
|
24
|
-
suiteName?: string | undefined;
|
|
25
|
-
testRunId?: string | undefined;
|
|
26
|
-
}, {
|
|
27
|
-
testLevel: TestLevel;
|
|
28
|
-
usernameOrAlias: string;
|
|
29
|
-
directory: string;
|
|
30
|
-
codeCoverage?: boolean | undefined;
|
|
31
|
-
async?: boolean | undefined;
|
|
32
|
-
classNames?: string[] | undefined;
|
|
33
|
-
methodNames?: string[] | undefined;
|
|
34
|
-
suiteName?: string | undefined;
|
|
35
|
-
testRunId?: string | undefined;
|
|
36
|
-
verbose?: boolean | undefined;
|
|
37
|
-
}>;
|
|
38
|
-
export type ApexRunTests = z.infer<typeof runApexTestsParam>;
|
|
39
|
-
export declare const testApex: (server: SfMcpServer) => void;
|
|
40
|
-
export {};
|