@salesforce/mcp 0.17.1-dev.0 → 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 -88
- package/lib/main-server-provider.d.ts +7 -0
- package/lib/main-server-provider.js +31 -0
- package/lib/registry.d.ts +3 -0
- package/lib/{tools/core/index.js → registry.js} +11 -4
- 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 -20
- 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/tools/{dynamic/sf-list-tools.js → sf-list-tools.js} +33 -9
- package/lib/tools/sf-suggest-cli-command.d.ts +25 -0
- package/lib/tools/{core/sf-suggest-cli-command.js → 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/utils/tools.d.ts +41 -0
- package/lib/{shared → utils}/tools.js +0 -69
- package/lib/utils/types.d.ts +5 -0
- package/package.json +8 -6
- package/README.md +0 -263
- package/lib/assets.d.ts +0 -44
- package/lib/shared/params.d.ts +0 -5
- package/lib/shared/params.js +0 -46
- package/lib/shared/tools.d.ts +0 -68
- 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/tools/core/index.d.ts +0 -3
- package/lib/tools/core/sf-get-username.d.ts +0 -17
- package/lib/tools/core/sf-get-username.js +0 -109
- package/lib/tools/core/sf-resume.d.ts +0 -20
- package/lib/tools/core/sf-resume.js +0 -149
- package/lib/tools/core/sf-suggest-cli-command.d.ts +0 -5
- package/lib/tools/data/index.d.ts +0 -1
- package/lib/tools/data/index.js +0 -17
- package/lib/tools/data/sf-query-org.d.ts +0 -20
- package/lib/tools/data/sf-query-org.js +0 -66
- 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-enable-tools.js +0 -42
- 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-deploy-metadata.d.ts +0 -27
- package/lib/tools/metadata/sf-deploy-metadata.js +0 -164
- package/lib/tools/metadata/sf-retrieve-metadata.d.ts +0 -2
- package/lib/tools/metadata/sf-retrieve-metadata.js +0 -128
- package/lib/tools/orgs/index.d.ts +0 -5
- package/lib/tools/orgs/index.js +0 -21
- package/lib/tools/orgs/sf-create-org-snapshot.d.ts +0 -23
- package/lib/tools/orgs/sf-create-org-snapshot.js +0 -88
- package/lib/tools/orgs/sf-create-scratch-org.d.ts +0 -50
- package/lib/tools/orgs/sf-create-scratch-org.js +0 -132
- package/lib/tools/orgs/sf-delete-org.d.ts +0 -14
- package/lib/tools/orgs/sf-delete-org.js +0 -65
- package/lib/tools/orgs/sf-list-all-orgs.d.ts +0 -11
- package/lib/tools/orgs/sf-list-all-orgs.js +0 -59
- package/lib/tools/orgs/sf-org-open.d.ts +0 -17
- package/lib/tools/orgs/sf-org-open.js +0 -57
- package/lib/tools/testing/index.d.ts +0 -2
- package/lib/tools/testing/index.js +0 -18
- package/lib/tools/testing/sf-test-agents.d.ts +0 -21
- package/lib/tools/testing/sf-test-agents.js +0 -84
- package/lib/tools/testing/sf-test-apex.d.ts +0 -40
- package/lib/tools/testing/sf-test-apex.js +0 -132
- package/lib/tools/users/index.d.ts +0 -1
- package/lib/tools/users/index.js +0 -17
- package/lib/tools/users/sf-assign-permission-set.d.ts +0 -20
- package/lib/tools/users/sf-assign-permission-set.js +0 -89
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/npm-shrinkwrap.json +0 -18827
- /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/{shared → utils}/types.js +0 -0
|
@@ -1,65 +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 { AuthRemover, Org } from '@salesforce/core';
|
|
18
|
-
import { textResponse } from '../../shared/utils.js';
|
|
19
|
-
import { directoryParam, usernameOrAliasParam } from '../../shared/params.js';
|
|
20
|
-
/*
|
|
21
|
-
* Delete a locally authorized Salesforce org
|
|
22
|
-
*
|
|
23
|
-
* Parameters:
|
|
24
|
-
* - directory: directory to change to before running the command
|
|
25
|
-
* - usernameOrAlias: Username or alias of the Salesforce org to delete.
|
|
26
|
-
*
|
|
27
|
-
* Returns:
|
|
28
|
-
* - textResponse: Deletion request response
|
|
29
|
-
*/
|
|
30
|
-
export const deleteOrgParams = z.object({
|
|
31
|
-
directory: directoryParam,
|
|
32
|
-
usernameOrAlias: usernameOrAliasParam,
|
|
33
|
-
});
|
|
34
|
-
export const registerToolDeleteOrg = (server) => {
|
|
35
|
-
server.tool('sf-delete-org', `Deletes specified salesforce org.
|
|
36
|
-
|
|
37
|
-
AGENT INSTRUCTIONS:
|
|
38
|
-
ALWAYS confirm with the user before deleting an org
|
|
39
|
-
|
|
40
|
-
Example usage:
|
|
41
|
-
Can you delete my org
|
|
42
|
-
Can you delete MyAliasedOrg
|
|
43
|
-
Can you delete test-fe2n4tc8pgku@example.com
|
|
44
|
-
`, deleteOrgParams.shape, {
|
|
45
|
-
title: 'Delete an Org',
|
|
46
|
-
}, async ({ directory, usernameOrAlias }) => {
|
|
47
|
-
try {
|
|
48
|
-
process.chdir(directory);
|
|
49
|
-
const org = await Org.create({ aliasOrUsername: usernameOrAlias });
|
|
50
|
-
await org.delete();
|
|
51
|
-
return textResponse(`Successfully deleted ${usernameOrAlias}`);
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
if (e instanceof Error && e.name === 'DomainNotFoundError') {
|
|
55
|
-
// the org has expired, so remote operations won't work
|
|
56
|
-
// let's clean up the files locally
|
|
57
|
-
const authRemover = await AuthRemover.create();
|
|
58
|
-
await authRemover.removeAuth(usernameOrAlias);
|
|
59
|
-
return textResponse(`Successfully deleted ${usernameOrAlias}`);
|
|
60
|
-
}
|
|
61
|
-
return textResponse(`Failed to delete org: ${e instanceof Error ? e.message : 'Unknown error'}`, true);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=sf-delete-org.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
export declare const listAllOrgsParamsSchema: z.ZodObject<{
|
|
4
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
directory: string;
|
|
7
|
-
}, {
|
|
8
|
-
directory: string;
|
|
9
|
-
}>;
|
|
10
|
-
export type ListAllOrgsOptions = z.infer<typeof listAllOrgsParamsSchema>;
|
|
11
|
-
export declare const registerToolListAllOrgs: (server: McpServer) => void;
|
|
@@ -1,59 +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 { getAllAllowedOrgs } from '../../shared/auth.js';
|
|
18
|
-
import { textResponse } from '../../shared/utils.js';
|
|
19
|
-
import { directoryParam } from '../../shared/params.js';
|
|
20
|
-
/*
|
|
21
|
-
* List all Salesforce orgs
|
|
22
|
-
*
|
|
23
|
-
* Lists all configured Salesforce orgs.
|
|
24
|
-
*
|
|
25
|
-
* Parameters:
|
|
26
|
-
* - directory: directory to change to before running the command
|
|
27
|
-
*
|
|
28
|
-
* Returns:
|
|
29
|
-
* - textResponse: List of configured Salesforce orgs
|
|
30
|
-
*/
|
|
31
|
-
export const listAllOrgsParamsSchema = z.object({
|
|
32
|
-
directory: directoryParam,
|
|
33
|
-
});
|
|
34
|
-
export const registerToolListAllOrgs = (server) => {
|
|
35
|
-
server.tool('sf-list-all-orgs', `Lists all configured Salesforce orgs.
|
|
36
|
-
|
|
37
|
-
AGENT INSTRUCTIONS:
|
|
38
|
-
DO NOT use this tool to try to determine which org a user wants, use #sf-get-username instead. Only use it if the user explicitly asks for a list of orgs.
|
|
39
|
-
|
|
40
|
-
Example usage:
|
|
41
|
-
Can you list all Salesforce orgs for me
|
|
42
|
-
List all Salesforce orgs
|
|
43
|
-
List all orgs
|
|
44
|
-
`, listAllOrgsParamsSchema.shape, {
|
|
45
|
-
title: 'List All Orgs',
|
|
46
|
-
readOnlyHint: true,
|
|
47
|
-
openWorldHint: false,
|
|
48
|
-
}, async ({ directory }) => {
|
|
49
|
-
try {
|
|
50
|
-
process.chdir(directory);
|
|
51
|
-
const orgs = await getAllAllowedOrgs();
|
|
52
|
-
return textResponse(`List of configured Salesforce orgs:\n\n${JSON.stringify(orgs, null, 2)}`);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
return textResponse(`Failed to list orgs: ${error instanceof Error ? error.message : 'Unknown error'}`, true);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=sf-list-all-orgs.js.map
|
|
@@ -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
|
-
directory: string;
|
|
9
|
-
usernameOrAlias: string;
|
|
10
|
-
filePath?: string | undefined;
|
|
11
|
-
}, {
|
|
12
|
-
directory: string;
|
|
13
|
-
usernameOrAlias: string;
|
|
14
|
-
filePath?: string | undefined;
|
|
15
|
-
}>;
|
|
16
|
-
export type OrgOpenParamsSchema = z.infer<typeof orgOpenParamsSchema>;
|
|
17
|
-
export declare const registerToolOrgOpen: (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 registerToolOrgOpen = (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,18 +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
|
-
export * from './sf-test-apex.js';
|
|
17
|
-
export * from './sf-test-agents.js';
|
|
18
|
-
//# sourceMappingURL=index.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
|
-
directory: string;
|
|
10
|
-
usernameOrAlias: string;
|
|
11
|
-
async: boolean;
|
|
12
|
-
agentApiName: string;
|
|
13
|
-
}, {
|
|
14
|
-
directory: string;
|
|
15
|
-
usernameOrAlias: string;
|
|
16
|
-
agentApiName: string;
|
|
17
|
-
async?: boolean | undefined;
|
|
18
|
-
}>;
|
|
19
|
-
export type AgentRunTests = z.infer<typeof runAgentTestsParam>;
|
|
20
|
-
export declare const registerToolTestAgent: (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 registerToolTestAgent = (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
|
-
directory: string;
|
|
19
|
-
usernameOrAlias: 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
|
-
directory: string;
|
|
29
|
-
usernameOrAlias: 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 registerToolTestApex: (server: SfMcpServer) => void;
|
|
40
|
-
export {};
|
|
@@ -1,132 +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 { TestService } from '@salesforce/apex-node';
|
|
18
|
-
import { Duration, ensureArray } 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 runApexTestsParam = z.object({
|
|
23
|
-
testLevel: z.enum(["RunLocalTests" /* TestLevel.RunLocalTests */, "RunAllTestsInOrg" /* TestLevel.RunAllTestsInOrg */, "RunSpecifiedTests" /* TestLevel.RunSpecifiedTests */]).describe(`Apex test level
|
|
24
|
-
|
|
25
|
-
AGENT INSTRUCTIONS
|
|
26
|
-
Choose the correct value based on what tests are meant to be executed in some of these ways:
|
|
27
|
-
|
|
28
|
-
RunLocalTests="Run all tests in the org, except the ones that originate from installed managed and unlocked packages."
|
|
29
|
-
RunAllTestsInOrg="Run all tests in the org, including tests of managed packages"
|
|
30
|
-
RunSpecifiedTests="Run the Apex tests I specify, these will be specified in the classNames parameter"
|
|
31
|
-
`),
|
|
32
|
-
classNames: z
|
|
33
|
-
.array(z.string())
|
|
34
|
-
.describe(`Apex tests classes to run.
|
|
35
|
-
if Running all tests, all tests should be listed
|
|
36
|
-
Run the tests, find apex classes matching the pattern **/classes/*.cls, that include the @isTest decorator in the file and then join their test names together with ','
|
|
37
|
-
`)
|
|
38
|
-
.optional(),
|
|
39
|
-
methodNames: z
|
|
40
|
-
.array(z.string())
|
|
41
|
-
.describe('Specific test method names, functions inside of an apex test class, must be joined with the Apex tests name')
|
|
42
|
-
.optional(),
|
|
43
|
-
async: z
|
|
44
|
-
.boolean()
|
|
45
|
-
.default(false)
|
|
46
|
-
.describe('Weather to wait for the test to finish (false) or enque the Apex tests and return the test run id (true)'),
|
|
47
|
-
suiteName: z.string().describe('a suite of apex test classes to run').optional(),
|
|
48
|
-
testRunId: z.string().default('an id of an in-progress, or completed apex test run').optional(),
|
|
49
|
-
verbose: z
|
|
50
|
-
.boolean()
|
|
51
|
-
.default(false)
|
|
52
|
-
.describe('If a user wants more test information in the context, or information about passing tests'),
|
|
53
|
-
codeCoverage: z
|
|
54
|
-
.boolean()
|
|
55
|
-
.default(false)
|
|
56
|
-
.describe('set to true if a user wants codecoverage calculated by the server'),
|
|
57
|
-
usernameOrAlias: usernameOrAliasParam,
|
|
58
|
-
directory: directoryParam,
|
|
59
|
-
});
|
|
60
|
-
/*
|
|
61
|
-
* Run Apex tests in a Salesforce org.
|
|
62
|
-
*
|
|
63
|
-
* Parameters:
|
|
64
|
-
* - testLevel: 'RunSpecifiedTests', 'RunLocalTests', 'RunAllTestsInOrg', used to specify the specific test-level.
|
|
65
|
-
* - classNames: if testLevel='RunSpecifiedTests', this will be the specified tests to run
|
|
66
|
-
* - usernameOrAlias: Username or alias of the Salesforce org to run tests in.
|
|
67
|
-
* - directory: Directory of the local project.
|
|
68
|
-
*
|
|
69
|
-
* Returns:
|
|
70
|
-
* - textResponse: Test result.
|
|
71
|
-
*/
|
|
72
|
-
export const registerToolTestApex = (server) => {
|
|
73
|
-
server.tool('sf-test-apex', `Run Apex tests in an org.
|
|
74
|
-
|
|
75
|
-
AGENT INSTRUCTIONS:
|
|
76
|
-
If the user doesn't specify what to test, take context from the currently open file
|
|
77
|
-
This will ONLY run APEX tests, NOT agent tests, lightning tests, flow tests, or any other type of test.
|
|
78
|
-
|
|
79
|
-
this should be chosen when a file in the 'classes' directory is mentioned
|
|
80
|
-
|
|
81
|
-
EXAMPLE USAGE:
|
|
82
|
-
Run tests A, B, C.
|
|
83
|
-
Run the myTestMethod in this file
|
|
84
|
-
Run this test and include success and failures
|
|
85
|
-
Run all tests in the org.
|
|
86
|
-
Test the "mySuite" suite asynchronously. I’ll check results later.
|
|
87
|
-
Run tests for this file and include coverage
|
|
88
|
-
What are the results for 707XXXXXXXXXXXX
|
|
89
|
-
`, runApexTestsParam.shape, {
|
|
90
|
-
title: 'Apex Tests',
|
|
91
|
-
openWorldHint: false,
|
|
92
|
-
}, async ({ testLevel, usernameOrAlias, classNames, directory, methodNames, suiteName, async, testRunId, verbose, codeCoverage, }) => {
|
|
93
|
-
if ((ensureArray(suiteName).length > 1 ||
|
|
94
|
-
ensureArray(methodNames).length > 1 ||
|
|
95
|
-
ensureArray(classNames).length > 1) &&
|
|
96
|
-
testLevel !== "RunSpecifiedTests" /* TestLevel.RunSpecifiedTests */) {
|
|
97
|
-
return textResponse("You can't specify which tests to run without setting testLevel='RunSpecifiedTests'", true);
|
|
98
|
-
}
|
|
99
|
-
if (!usernameOrAlias)
|
|
100
|
-
return textResponse('The usernameOrAlias parameter is required, if the user did not specify one use the #sf-get-username tool', true);
|
|
101
|
-
// needed for org allowlist to work
|
|
102
|
-
process.chdir(directory);
|
|
103
|
-
const connection = await getConnection(usernameOrAlias);
|
|
104
|
-
try {
|
|
105
|
-
const testService = new TestService(connection);
|
|
106
|
-
let result;
|
|
107
|
-
if (testRunId) {
|
|
108
|
-
// we just need to get the test results
|
|
109
|
-
result = await testService.reportAsyncResults(testRunId, codeCoverage);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// we need to run tests
|
|
113
|
-
const payload = await testService.buildAsyncPayload(testLevel, methodNames?.join(','), classNames?.join(','), suiteName);
|
|
114
|
-
result = await testService.runTestAsynchronous(payload, codeCoverage, async, undefined, undefined, Duration.minutes(10));
|
|
115
|
-
if (async) {
|
|
116
|
-
return textResponse(`Test Run Id: ${JSON.stringify(result)}`);
|
|
117
|
-
}
|
|
118
|
-
// the user waited for the full results, we know they're TestResult
|
|
119
|
-
result = result;
|
|
120
|
-
}
|
|
121
|
-
if (!verbose) {
|
|
122
|
-
// aka concise, filter out passing tests
|
|
123
|
-
result.tests = result.tests.filter((test) => test.outcome === "Fail" /* ApexTestResultOutcome.Fail */);
|
|
124
|
-
}
|
|
125
|
-
return textResponse(`Test result: ${JSON.stringify(result)}`);
|
|
126
|
-
}
|
|
127
|
-
catch (e) {
|
|
128
|
-
return textResponse(`Failed to run Apex Tests: ${e instanceof Error ? e.message : 'Unknown error'}`, true);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
//# sourceMappingURL=sf-test-apex.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './sf-assign-permission-set.js';
|
package/lib/tools/users/index.js
DELETED
|
@@ -1,17 +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
|
-
export * from './sf-assign-permission-set.js';
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { SfMcpServer } from '../../sf-mcp-server.js';
|
|
3
|
-
export declare const assignPermissionSetParamsSchema: z.ZodObject<{
|
|
4
|
-
permissionSetName: z.ZodString;
|
|
5
|
-
usernameOrAlias: z.ZodString;
|
|
6
|
-
onBehalfOf: z.ZodOptional<z.ZodString>;
|
|
7
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
directory: string;
|
|
10
|
-
usernameOrAlias: string;
|
|
11
|
-
permissionSetName: string;
|
|
12
|
-
onBehalfOf?: string | undefined;
|
|
13
|
-
}, {
|
|
14
|
-
directory: string;
|
|
15
|
-
usernameOrAlias: string;
|
|
16
|
-
permissionSetName: string;
|
|
17
|
-
onBehalfOf?: string | undefined;
|
|
18
|
-
}>;
|
|
19
|
-
export type AssignPermissionSetOptions = z.infer<typeof assignPermissionSetParamsSchema>;
|
|
20
|
-
export declare const registerToolAssignPermissionSet: (server: SfMcpServer) => void;
|
|
@@ -1,89 +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 { Org, StateAggregator, User } from '@salesforce/core';
|
|
17
|
-
import { z } from 'zod';
|
|
18
|
-
import { directoryParam, usernameOrAliasParam } from '../../shared/params.js';
|
|
19
|
-
import { textResponse } from '../../shared/utils.js';
|
|
20
|
-
import { getConnection } from '../../shared/auth.js';
|
|
21
|
-
/*
|
|
22
|
-
* Assign permission set
|
|
23
|
-
*
|
|
24
|
-
* Assign a permission set to one or more org users.
|
|
25
|
-
*
|
|
26
|
-
* Parameters:
|
|
27
|
-
* - permissionSetName: Permission set to assign (required)
|
|
28
|
-
* Example: "Set the permission set MyPermSet", "Set the perm set MyPermSet"
|
|
29
|
-
* - usernameOrAlias: Username or alias for the Salesforce org (required)
|
|
30
|
-
* - onBehalfOf: Username or alias to assign the permission set to (optional)
|
|
31
|
-
* Note: This is only used when "on behalf of" is explicitly mentioned.
|
|
32
|
-
* Otherwise, the permission will be set to the usernameOrAlias user.
|
|
33
|
-
* Example: "Set the permission set MyPermSet on behalf of my-alias"
|
|
34
|
-
*
|
|
35
|
-
* Returns:
|
|
36
|
-
* - textResponse: Permission set assignment result
|
|
37
|
-
*/
|
|
38
|
-
export const assignPermissionSetParamsSchema = z.object({
|
|
39
|
-
permissionSetName: z.string().describe(`A single permission set to assign
|
|
40
|
-
|
|
41
|
-
EXAMPLE USAGE:
|
|
42
|
-
Set the permission set MyPermSet
|
|
43
|
-
Set the perm set MyPermSet`),
|
|
44
|
-
usernameOrAlias: usernameOrAliasParam,
|
|
45
|
-
onBehalfOf: z.string().optional()
|
|
46
|
-
.describe(`A single username or alias (other than the usernameOrAlias) to assign the permission set to
|
|
47
|
-
|
|
48
|
-
AGENT INSTRUCTIONS:
|
|
49
|
-
If the user does not specifically say "on behalf of" this will be empty.
|
|
50
|
-
If the user does specifically say "on behalf of", but it is unclear what the target-org is, run the #sf-get-username tool.
|
|
51
|
-
In that case, use the usernameOrAlias parameter as the org to assign the permission set to.
|
|
52
|
-
|
|
53
|
-
USAGE EXAMPLE:
|
|
54
|
-
Assign the permission set MyPermSet.
|
|
55
|
-
Set the permission set MyPermSet on behalf of test-3uyb8kmftiu@example.com.
|
|
56
|
-
Set the permission set MyPermSet on behalf of my-alias.`),
|
|
57
|
-
directory: directoryParam,
|
|
58
|
-
});
|
|
59
|
-
export const registerToolAssignPermissionSet = (server) => {
|
|
60
|
-
server.tool('sf-assign-permission-set', 'Assign a permission set to one or more org users.', assignPermissionSetParamsSchema.shape, {
|
|
61
|
-
title: 'Assign Permission Set',
|
|
62
|
-
openWorldHint: false,
|
|
63
|
-
}, async ({ permissionSetName, usernameOrAlias, onBehalfOf, directory }) => {
|
|
64
|
-
try {
|
|
65
|
-
if (!usernameOrAlias)
|
|
66
|
-
return textResponse('The usernameOrAlias parameter is required, if the user did not specify one use the #sf-get-username tool', true);
|
|
67
|
-
process.chdir(directory);
|
|
68
|
-
// We build the connection from the usernameOrAlias
|
|
69
|
-
const connection = await getConnection(usernameOrAlias);
|
|
70
|
-
// We need to clear the instance so we know we have the most up to date aliases
|
|
71
|
-
// If a user sets an alias after server start up, it was not getting picked up
|
|
72
|
-
await StateAggregator.clearInstanceAsync();
|
|
73
|
-
// Must NOT be nullish coalescing (??) In case the LLM uses and empty string
|
|
74
|
-
const assignTo = (await StateAggregator.getInstance()).aliases.resolveUsername(onBehalfOf || usernameOrAlias);
|
|
75
|
-
if (!assignTo.includes('@')) {
|
|
76
|
-
return textResponse('Unable to resolve the username for alias. Make sure it is correct', true);
|
|
77
|
-
}
|
|
78
|
-
const org = await Org.create({ connection });
|
|
79
|
-
const user = await User.create({ org });
|
|
80
|
-
const queryResult = await connection.singleRecordQuery(`SELECT Id FROM User WHERE Username='${assignTo}'`);
|
|
81
|
-
await user.assignPermissionSets(queryResult.Id, [permissionSetName]);
|
|
82
|
-
return textResponse(`Assigned ${permissionSetName} to ${assignTo}`);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
return textResponse(`Failed to assign permission set: ${error instanceof Error ? error.message : 'Unknown error'}`, true);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=sf-assign-permission-set.js.map
|