@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,164 +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, SfError, SfProject } from '@salesforce/core';
|
|
18
|
-
import { SourceTracking } from '@salesforce/source-tracking';
|
|
19
|
-
import { ComponentSet, 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 deployMetadataParams = z.object({
|
|
26
|
-
sourceDir: z
|
|
27
|
-
.array(z.string())
|
|
28
|
-
.describe('Path to the local source files to deploy. Leave this unset if the user is vague about what to deploy.')
|
|
29
|
-
.optional(),
|
|
30
|
-
manifest: z.string().describe('Full file path for manifest (XML file) of components to deploy.').optional(),
|
|
31
|
-
// `RunSpecifiedTests` is excluded on purpose because the tool sets this level when Apex tests to run are passed in.
|
|
32
|
-
//
|
|
33
|
-
// Can be left unset to let the org decide which test level to use:
|
|
34
|
-
// https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_deploy_running_tests.htm
|
|
35
|
-
apexTestLevel: z
|
|
36
|
-
.enum(['NoTestRun', 'RunLocalTests', 'RunAllTestsInOrg'])
|
|
37
|
-
.optional()
|
|
38
|
-
.describe(`Apex test level to use during deployment.
|
|
39
|
-
|
|
40
|
-
AGENT INSTRUCTIONS
|
|
41
|
-
Set this only if the user specifically ask to run apex tests in some of these ways:
|
|
42
|
-
|
|
43
|
-
NoTestRun="No tests are run"
|
|
44
|
-
RunLocalTests="Run all tests in the org, except the ones that originate from installed managed and unlocked packages."
|
|
45
|
-
RunAllTestsInOrg="Run all tests in the org, including tests of managed packages"
|
|
46
|
-
|
|
47
|
-
Don't set this param if "apexTests" is also set.
|
|
48
|
-
`),
|
|
49
|
-
apexTests: z
|
|
50
|
-
.array(z.string())
|
|
51
|
-
.describe(`Apex tests classes to run.
|
|
52
|
-
|
|
53
|
-
Set this param if the user ask an Apex test to be run during deployment.
|
|
54
|
-
`)
|
|
55
|
-
.optional(),
|
|
56
|
-
usernameOrAlias: usernameOrAliasParam,
|
|
57
|
-
directory: directoryParam,
|
|
58
|
-
});
|
|
59
|
-
/*
|
|
60
|
-
* Deploy metadata to a Salesforce org.
|
|
61
|
-
*
|
|
62
|
-
* Parameters:
|
|
63
|
-
* - sourceDir: Path to the local source files to deploy.
|
|
64
|
-
* - manifest: Full file path for manifest (XML file) of components to deploy.
|
|
65
|
-
* - apexTestLevel: Apex test level to use during deployment.
|
|
66
|
-
* - apexTests: Apex tests classes to run.
|
|
67
|
-
* - usernameOrAlias: Username or alias of the Salesforce org to deploy to.
|
|
68
|
-
* - directory: Directory of the local project.
|
|
69
|
-
*
|
|
70
|
-
* Returns:
|
|
71
|
-
* - textResponse: Deploy result.
|
|
72
|
-
*/
|
|
73
|
-
export const registerToolDeployMetadata = (server) => {
|
|
74
|
-
server.tool('sf-deploy-metadata', `Deploy metadata to an org from your local project.
|
|
75
|
-
|
|
76
|
-
AGENT INSTRUCTIONS:
|
|
77
|
-
If the user doesn't specify what to deploy exactly ("deploy my changes"), leave the "sourceDir" and "manifest" params empty so the tool calculates which files to deploy.
|
|
78
|
-
|
|
79
|
-
EXAMPLE USAGE:
|
|
80
|
-
Deploy changes to my org
|
|
81
|
-
Deploy this file to my org
|
|
82
|
-
Deploy the manifest
|
|
83
|
-
Deploy X metadata to my org
|
|
84
|
-
Deploy X to my org and run A,B and C apex tests.
|
|
85
|
-
`, deployMetadataParams.shape, {
|
|
86
|
-
title: 'Deploy Metadata',
|
|
87
|
-
destructiveHint: true,
|
|
88
|
-
openWorldHint: false,
|
|
89
|
-
}, async ({ sourceDir, usernameOrAlias, apexTests, apexTestLevel, directory, manifest }) => {
|
|
90
|
-
if (apexTests && apexTestLevel) {
|
|
91
|
-
return textResponse("You can't specify both `apexTests` and `apexTestLevel` parameters.", true);
|
|
92
|
-
}
|
|
93
|
-
if (sourceDir && manifest) {
|
|
94
|
-
return textResponse("You can't specify both `sourceDir` and `manifest` parameters.", true);
|
|
95
|
-
}
|
|
96
|
-
if (!usernameOrAlias)
|
|
97
|
-
return textResponse('The usernameOrAlias parameter is required, if the user did not specify one use the #sf-get-username tool', true);
|
|
98
|
-
// needed for org allowlist to work
|
|
99
|
-
process.chdir(directory);
|
|
100
|
-
const connection = await getConnection(usernameOrAlias);
|
|
101
|
-
const project = await SfProject.resolve(directory);
|
|
102
|
-
const org = await Org.create({ connection });
|
|
103
|
-
if (!sourceDir && !manifest && !(await org.tracksSource())) {
|
|
104
|
-
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 deploy.', true);
|
|
105
|
-
}
|
|
106
|
-
let jobId = '';
|
|
107
|
-
try {
|
|
108
|
-
const stl = await SourceTracking.create({
|
|
109
|
-
org,
|
|
110
|
-
project,
|
|
111
|
-
subscribeSDREvents: true,
|
|
112
|
-
});
|
|
113
|
-
const componentSet = await buildDeployComponentSet(connection, project, stl, sourceDir, manifest);
|
|
114
|
-
if (componentSet.size === 0) {
|
|
115
|
-
// STL found no changes
|
|
116
|
-
return textResponse('No local changes to deploy were found.');
|
|
117
|
-
}
|
|
118
|
-
const deploy = await componentSet.deploy({
|
|
119
|
-
usernameOrConnection: connection,
|
|
120
|
-
apiOptions: {
|
|
121
|
-
...(apexTests ? { runTests: apexTests, testLevel: 'RunSpecifiedTests' } : {}),
|
|
122
|
-
...(apexTestLevel ? { testLevel: apexTestLevel } : {}),
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
jobId = deploy.id ?? '';
|
|
126
|
-
// polling freq. is set dynamically by SDR based on the component set size.
|
|
127
|
-
const result = await deploy.pollStatus({
|
|
128
|
-
timeout: Duration.minutes(10),
|
|
129
|
-
});
|
|
130
|
-
return textResponse(`Deploy result: ${JSON.stringify(result.response)}`, !result.response.success);
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
const err = SfError.wrap(error);
|
|
134
|
-
if (err.message.includes('timed out')) {
|
|
135
|
-
return textResponse(`
|
|
136
|
-
YOU MUST inform the user that the deploy timed out and if they want to resume the deploy, they can use the #sf-resume tool
|
|
137
|
-
and ${jobId} for the jobId parameter.`, true);
|
|
138
|
-
}
|
|
139
|
-
return textResponse(`Failed to deploy metadata: ${err.message}`, true);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
async function buildDeployComponentSet(connection, project, stl, sourceDir, manifestPath) {
|
|
144
|
-
if (sourceDir || manifestPath) {
|
|
145
|
-
return ComponentSetBuilder.build({
|
|
146
|
-
apiversion: connection.getApiVersion(),
|
|
147
|
-
sourceapiversion: ensureString((await project.resolveProjectConfig()).sourceApiVersion),
|
|
148
|
-
sourcepath: sourceDir,
|
|
149
|
-
...(manifestPath
|
|
150
|
-
? {
|
|
151
|
-
manifest: {
|
|
152
|
-
manifestPath,
|
|
153
|
-
directoryPaths: project.getUniquePackageDirectories().map((pDir) => pDir.fullPath),
|
|
154
|
-
},
|
|
155
|
-
}
|
|
156
|
-
: {}),
|
|
157
|
-
projectDir: stl?.projectPath,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
// No specific metadata requested to deploy, build component set from STL.
|
|
161
|
-
const cs = (await stl.localChangesAsComponentSet(false))[0] ?? new ComponentSet(undefined, stl.registry);
|
|
162
|
-
return cs;
|
|
163
|
-
}
|
|
164
|
-
//# sourceMappingURL=sf-deploy-metadata.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 registerToolRetrieveMetadata = (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
|
package/lib/tools/orgs/index.js
DELETED
|
@@ -1,21 +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-list-all-orgs.js';
|
|
17
|
-
export * from './sf-delete-org.js';
|
|
18
|
-
export * from './sf-create-scratch-org.js';
|
|
19
|
-
export * from './sf-create-org-snapshot.js';
|
|
20
|
-
export * from './sf-org-open.js';
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
export declare const createOrgSnapshotParams: z.ZodObject<{
|
|
4
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
-
devHub: z.ZodString;
|
|
6
|
-
sourceOrg: z.ZodString;
|
|
7
|
-
description: z.ZodOptional<z.ZodString>;
|
|
8
|
-
name: z.ZodDefault<z.ZodString>;
|
|
9
|
-
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
name: string;
|
|
11
|
-
directory: string;
|
|
12
|
-
devHub: string;
|
|
13
|
-
sourceOrg: string;
|
|
14
|
-
description?: string | undefined;
|
|
15
|
-
}, {
|
|
16
|
-
directory: string;
|
|
17
|
-
devHub: string;
|
|
18
|
-
sourceOrg: string;
|
|
19
|
-
name?: string | undefined;
|
|
20
|
-
description?: string | undefined;
|
|
21
|
-
}>;
|
|
22
|
-
export type CreateOrgSnapshotOptions = z.infer<typeof createOrgSnapshotParams>;
|
|
23
|
-
export declare const registerToolCreateOrgSnapshot: (server: McpServer) => void;
|
|
@@ -1,88 +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 { textResponse } from '../../shared/utils.js';
|
|
19
|
-
import { directoryParam, usernameOrAliasParam } from '../../shared/params.js';
|
|
20
|
-
import { getConnection } from '../../shared/auth.js';
|
|
21
|
-
/*
|
|
22
|
-
* Create a new scratch org snapshot
|
|
23
|
-
*
|
|
24
|
-
* Parameters:
|
|
25
|
-
* - directory: directory to change to before running the command
|
|
26
|
-
* - devHub: Username or alias of the Dev Hub org
|
|
27
|
-
* - sourceOrg: ID or locally authenticated username or alias of scratch org to snapshot.
|
|
28
|
-
* - description: a description given to the snapshot
|
|
29
|
-
* - name: Unique name of snapshot
|
|
30
|
-
* Returns:
|
|
31
|
-
* - textResponse:
|
|
32
|
-
*/
|
|
33
|
-
export const createOrgSnapshotParams = z.object({
|
|
34
|
-
directory: directoryParam,
|
|
35
|
-
devHub: usernameOrAliasParam.describe('The default devhub username, use the #sf-get-username tool to get the default devhub if unsure'),
|
|
36
|
-
sourceOrg: usernameOrAliasParam.describe('The org username or alias to create a snapshot of, use the #sf-get-username tool to get the default target org if unsure'),
|
|
37
|
-
description: z.string().describe(' Description of snapshot.').optional(),
|
|
38
|
-
name: z.string().describe('Unique name of snapshot').max(15).default(Date.now().toString().substring(0, 15)),
|
|
39
|
-
});
|
|
40
|
-
export const registerToolCreateOrgSnapshot = (server) => {
|
|
41
|
-
server.tool('sf-create-org-snapshot', `Creates a new snapshot of an org
|
|
42
|
-
|
|
43
|
-
AGENT INSTRUCTIONS:
|
|
44
|
-
|
|
45
|
-
Example usage:
|
|
46
|
-
Create a snapshot called 07042025
|
|
47
|
-
create a snapshot called 07042025 with the description, "this is a snapshot for commit 5b1a09b1743 - new login flow working"
|
|
48
|
-
create a snapshot of my MyScratch in myDevHub
|
|
49
|
-
`, createOrgSnapshotParams.shape, {
|
|
50
|
-
title: 'Create a new snapshot',
|
|
51
|
-
}, async ({ directory, devHub, description, name, sourceOrg }) => {
|
|
52
|
-
try {
|
|
53
|
-
process.chdir(directory);
|
|
54
|
-
const sourceOrgId = (await Org.create({ aliasOrUsername: sourceOrg })).getOrgId();
|
|
55
|
-
const devHubConnection = await getConnection(devHub);
|
|
56
|
-
const createResponse = await devHubConnection.sobject('OrgSnapshot').create({
|
|
57
|
-
SourceOrg: sourceOrgId,
|
|
58
|
-
Description: description,
|
|
59
|
-
SnapshotName: name,
|
|
60
|
-
Content: 'metadatadata',
|
|
61
|
-
});
|
|
62
|
-
if (createResponse.success === false) {
|
|
63
|
-
return textResponse(`An error while created the org snapshot: ${JSON.stringify(createResponse)}`, true);
|
|
64
|
-
}
|
|
65
|
-
const result = await devHubConnection.singleRecordQuery(`SELECT Id,
|
|
66
|
-
SnapshotName,
|
|
67
|
-
Description,
|
|
68
|
-
Status,
|
|
69
|
-
SourceOrg,
|
|
70
|
-
CreatedDate,
|
|
71
|
-
LastModifiedDate,
|
|
72
|
-
ExpirationDate,
|
|
73
|
-
Error FROM OrgSnapshot WHERE Id = '${createResponse.id}'`);
|
|
74
|
-
return textResponse(`Successfully created the org snapshot: ${JSON.stringify(result)}`);
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
const e = error;
|
|
78
|
-
// dev hub does not have snapshot pref enabled
|
|
79
|
-
if (e.name === 'NOT_FOUND') {
|
|
80
|
-
return textResponse("Scratch Org Snapshots isn't enabled for your Dev Hub.", true);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
return textResponse(`Error: ${e.name} : ${e.message}`, true);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
//# sourceMappingURL=sf-create-org-snapshot.js.map
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
export declare const createScratchOrgParams: z.ZodObject<{
|
|
4
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
-
devHub: z.ZodString;
|
|
6
|
-
duration: z.ZodDefault<z.ZodNumber>;
|
|
7
|
-
edition: z.ZodOptional<z.ZodEnum<["developer", "enterprise", "group", "professional", "partner-developer", "partner-enterprise", "partner-group", "partner-professional"]>>;
|
|
8
|
-
definitionFile: z.ZodDefault<z.ZodString>;
|
|
9
|
-
alias: z.ZodOptional<z.ZodString>;
|
|
10
|
-
async: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
-
setDefault: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
-
snapshot: z.ZodOptional<z.ZodString>;
|
|
13
|
-
sourceOrg: z.ZodOptional<z.ZodString>;
|
|
14
|
-
username: z.ZodOptional<z.ZodString>;
|
|
15
|
-
description: z.ZodOptional<z.ZodString>;
|
|
16
|
-
orgName: z.ZodOptional<z.ZodString>;
|
|
17
|
-
adminEmail: z.ZodOptional<z.ZodString>;
|
|
18
|
-
}, "strip", z.ZodTypeAny, {
|
|
19
|
-
directory: string;
|
|
20
|
-
devHub: string;
|
|
21
|
-
duration: number;
|
|
22
|
-
definitionFile: string;
|
|
23
|
-
async: boolean;
|
|
24
|
-
username?: string | undefined;
|
|
25
|
-
description?: string | undefined;
|
|
26
|
-
snapshot?: string | undefined;
|
|
27
|
-
alias?: string | undefined;
|
|
28
|
-
edition?: "group" | "developer" | "enterprise" | "professional" | "partner-developer" | "partner-enterprise" | "partner-group" | "partner-professional" | undefined;
|
|
29
|
-
setDefault?: boolean | undefined;
|
|
30
|
-
sourceOrg?: string | undefined;
|
|
31
|
-
orgName?: string | undefined;
|
|
32
|
-
adminEmail?: string | undefined;
|
|
33
|
-
}, {
|
|
34
|
-
directory: string;
|
|
35
|
-
devHub: string;
|
|
36
|
-
username?: string | undefined;
|
|
37
|
-
description?: string | undefined;
|
|
38
|
-
snapshot?: string | undefined;
|
|
39
|
-
alias?: string | undefined;
|
|
40
|
-
duration?: number | undefined;
|
|
41
|
-
edition?: "group" | "developer" | "enterprise" | "professional" | "partner-developer" | "partner-enterprise" | "partner-group" | "partner-professional" | undefined;
|
|
42
|
-
definitionFile?: string | undefined;
|
|
43
|
-
async?: boolean | undefined;
|
|
44
|
-
setDefault?: boolean | undefined;
|
|
45
|
-
sourceOrg?: string | undefined;
|
|
46
|
-
orgName?: string | undefined;
|
|
47
|
-
adminEmail?: string | undefined;
|
|
48
|
-
}>;
|
|
49
|
-
export type CreateScratchOrgOptions = z.infer<typeof createScratchOrgParams>;
|
|
50
|
-
export declare const registerToolCreateScratchOrg: (server: McpServer) => void;
|
|
@@ -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 { join } from 'node:path';
|
|
17
|
-
import * as fs from 'node:fs';
|
|
18
|
-
import { z } from 'zod';
|
|
19
|
-
import { Org, scratchOrgCreate } from '@salesforce/core';
|
|
20
|
-
import { Duration } from '@salesforce/kit';
|
|
21
|
-
import { textResponse } from '../../shared/utils.js';
|
|
22
|
-
import { directoryParam, usernameOrAliasParam } from '../../shared/params.js';
|
|
23
|
-
/*
|
|
24
|
-
* Create a new scratch org
|
|
25
|
-
*
|
|
26
|
-
* Parameters:
|
|
27
|
-
* - directory: directory to change to before running the command
|
|
28
|
-
* - usernameOrAlias: Username or alias of the Salesforce DevHub org to use to create from
|
|
29
|
-
* - duration: Duration in days of the scratch org to exist, default 7
|
|
30
|
-
* - edition: Edition of the scratch org
|
|
31
|
-
* - definitionFile: path to the scratch org definition file, default config/project-scratch-def.json
|
|
32
|
-
* - alias: Alias to use for the scratch org
|
|
33
|
-
* - async: Wait for the scratch org creation process to finish, default false
|
|
34
|
-
* - setDefault: set the newly created org as default-target-org
|
|
35
|
-
* - snapshot: The snapshot name to use when creating a scratch org
|
|
36
|
-
* - sourceOrg: 15-character ID of the org shape that the new scratch org is based on
|
|
37
|
-
* - username: Username of the scratch org admin user
|
|
38
|
-
* - description: a description given to the scratch org
|
|
39
|
-
* - orgName: Name of the scratch org
|
|
40
|
-
* - adminEmail: Email address that will be applied to the org's admin user.
|
|
41
|
-
* Returns:
|
|
42
|
-
* - textResponse:
|
|
43
|
-
*/
|
|
44
|
-
export const createScratchOrgParams = z.object({
|
|
45
|
-
directory: directoryParam,
|
|
46
|
-
devHub: usernameOrAliasParam.describe('The default devhub username, use the #sf-get-username tool to get the default devhub if unsure'),
|
|
47
|
-
duration: z.number().default(7).describe('number of days before the org expires'),
|
|
48
|
-
edition: z
|
|
49
|
-
.enum([
|
|
50
|
-
'developer',
|
|
51
|
-
'enterprise',
|
|
52
|
-
'group',
|
|
53
|
-
'professional',
|
|
54
|
-
'partner-developer',
|
|
55
|
-
'partner-enterprise',
|
|
56
|
-
'partner-group',
|
|
57
|
-
'partner-professional',
|
|
58
|
-
])
|
|
59
|
-
.optional(),
|
|
60
|
-
definitionFile: z
|
|
61
|
-
.string()
|
|
62
|
-
.default(join('config', 'project-scratch-def.json'))
|
|
63
|
-
.describe('a normalized path to a scratch definition json file'),
|
|
64
|
-
alias: z.string().describe('the alias to be used for the scratch org').optional(),
|
|
65
|
-
async: z
|
|
66
|
-
.boolean()
|
|
67
|
-
.default(false)
|
|
68
|
-
.describe('Whether to wait for the org creation process to finish (false) or just quickly return the ID (true)'),
|
|
69
|
-
setDefault: z
|
|
70
|
-
.boolean()
|
|
71
|
-
.optional()
|
|
72
|
-
.describe('If true, will set the newly created scratch org to be the default-target-org'),
|
|
73
|
-
snapshot: z.string().describe('The snapshot name to use when creating a scratch org').optional(),
|
|
74
|
-
sourceOrg: z
|
|
75
|
-
.string()
|
|
76
|
-
.length(15)
|
|
77
|
-
.describe('15-character ID of the org shape that the new scratch org is based on')
|
|
78
|
-
.optional(),
|
|
79
|
-
username: z.string().describe('Username of the scratch org admin user').optional(),
|
|
80
|
-
description: z.string().describe('a description given to the scratch org').optional(),
|
|
81
|
-
orgName: z.string().describe('Name of the scratch org').optional(),
|
|
82
|
-
adminEmail: z.string().describe("Email address that will be applied to the org's admin user.").optional(),
|
|
83
|
-
});
|
|
84
|
-
export const registerToolCreateScratchOrg = (server) => {
|
|
85
|
-
server.tool('sf-create-scratch-org', `Creates a scratch org with the specified parameters.
|
|
86
|
-
|
|
87
|
-
AGENT INSTRUCTIONS:
|
|
88
|
-
|
|
89
|
-
Example usage:
|
|
90
|
-
Create a scratch org
|
|
91
|
-
create a scratch org with the definition file myDefinition.json that lasts 3 days
|
|
92
|
-
create a scratch org aliased as MyNewOrg and set as default and don't wait for it to finish
|
|
93
|
-
`, createScratchOrgParams.shape, {
|
|
94
|
-
title: 'Create a scratch org',
|
|
95
|
-
}, async ({ directory, devHub, orgName, adminEmail, description, snapshot, sourceOrg, username, edition, setDefault, async, duration, alias, definitionFile, }) => {
|
|
96
|
-
try {
|
|
97
|
-
process.chdir(directory);
|
|
98
|
-
const hubOrProd = await Org.create({ aliasOrUsername: devHub });
|
|
99
|
-
const requestParams = {
|
|
100
|
-
hubOrg: hubOrProd,
|
|
101
|
-
durationDays: duration,
|
|
102
|
-
wait: async ? Duration.minutes(0) : Duration.minutes(10),
|
|
103
|
-
orgConfig: {
|
|
104
|
-
...(definitionFile
|
|
105
|
-
? JSON.parse(await fs.promises.readFile(definitionFile, 'utf-8'))
|
|
106
|
-
: {}),
|
|
107
|
-
...(edition ? { edition } : {}),
|
|
108
|
-
...(snapshot ? { snapshot } : {}),
|
|
109
|
-
...(username ? { username } : {}),
|
|
110
|
-
...(description ? { description } : {}),
|
|
111
|
-
...(orgName ? { orgName } : {}),
|
|
112
|
-
...(sourceOrg ? { sourceOrg } : {}),
|
|
113
|
-
...(adminEmail ? { adminEmail } : {}),
|
|
114
|
-
},
|
|
115
|
-
alias,
|
|
116
|
-
setDefault,
|
|
117
|
-
tracksSource: true,
|
|
118
|
-
};
|
|
119
|
-
const result = await scratchOrgCreate(requestParams);
|
|
120
|
-
if (async) {
|
|
121
|
-
return textResponse(`Successfully enqueued scratch org with job Id: ${JSON.stringify(result.scratchOrgInfo?.Id)} use the #sf-resume tool to resume this operation`);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
return textResponse(`Successfully created scratch org ${JSON.stringify(result)}`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
catch (e) {
|
|
128
|
-
return textResponse(`Failed to create org: ${e instanceof Error ? e.message : 'Unknown error'}`, true);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
//# sourceMappingURL=sf-create-scratch-org.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
export declare const deleteOrgParams: z.ZodObject<{
|
|
4
|
-
directory: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
-
usernameOrAlias: z.ZodString;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
directory: string;
|
|
8
|
-
usernameOrAlias: string;
|
|
9
|
-
}, {
|
|
10
|
-
directory: string;
|
|
11
|
-
usernameOrAlias: string;
|
|
12
|
-
}>;
|
|
13
|
-
export type DeleteOrgOptions = z.infer<typeof deleteOrgParams>;
|
|
14
|
-
export declare const registerToolDeleteOrg: (server: McpServer) => void;
|