@salesforce/b2c-dx-mcp 0.0.1 → 0.3.2
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/README.md +422 -29
- package/bin/run.cmd +3 -0
- package/bin/run.js +27 -0
- package/content/auth.md +62 -0
- package/content/components.md +123 -0
- package/content/config.md +180 -0
- package/content/data-fetching.md +323 -0
- package/content/extensions.md +80 -0
- package/content/i18n.md +121 -0
- package/content/page-designer.md +86 -0
- package/content/performance.md +80 -0
- package/content/pitfalls.md +141 -0
- package/content/quick-reference.md +226 -0
- package/content/state-management.md +75 -0
- package/content/styling.md +51 -0
- package/content/testing.md +232 -0
- package/dist/commands/mcp.d.ts +110 -0
- package/dist/commands/mcp.js +333 -0
- package/dist/registry.d.ts +37 -0
- package/dist/registry.js +212 -0
- package/dist/server.d.ts +46 -0
- package/dist/server.js +98 -0
- package/dist/services.d.ts +168 -0
- package/dist/services.js +191 -0
- package/dist/tools/adapter.d.ts +201 -0
- package/dist/tools/adapter.js +220 -0
- package/dist/tools/cartridges/index.d.ts +20 -0
- package/dist/tools/cartridges/index.js +101 -0
- package/dist/tools/index.d.ts +17 -0
- package/dist/tools/index.js +25 -0
- package/dist/tools/mrt/index.d.ts +20 -0
- package/dist/tools/mrt/index.js +101 -0
- package/dist/tools/pwav3/index.d.ts +13 -0
- package/dist/tools/pwav3/index.js +78 -0
- package/dist/tools/scapi/index.d.ts +9 -0
- package/dist/tools/scapi/index.js +68 -0
- package/dist/tools/storefrontnext/developer-guidelines.d.ts +9 -0
- package/dist/tools/storefrontnext/developer-guidelines.js +140 -0
- package/dist/tools/storefrontnext/index.d.ts +13 -0
- package/dist/tools/storefrontnext/index.js +83 -0
- package/dist/utils/constants.d.ts +16 -0
- package/dist/utils/constants.js +18 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/types.d.ts +45 -0
- package/dist/utils/types.js +7 -0
- package/oclif.manifest.json +377 -0
- package/package.json +123 -7
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Cartridges toolset for B2C Commerce code operations.
|
|
8
|
+
*
|
|
9
|
+
* This toolset provides MCP tools for cartridge and code version management.
|
|
10
|
+
*
|
|
11
|
+
* @module tools/cartridges
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { createToolAdapter, jsonResult } from '../adapter.js';
|
|
15
|
+
import { findAndDeployCartridges } from '@salesforce/b2c-tooling-sdk/operations/code';
|
|
16
|
+
import { getLogger } from '@salesforce/b2c-tooling-sdk/logging';
|
|
17
|
+
/**
|
|
18
|
+
* Creates the cartridge_deploy tool.
|
|
19
|
+
*
|
|
20
|
+
* Deploys cartridges to a B2C Commerce instance via WebDAV:
|
|
21
|
+
* 1. Finds cartridges by `.project` files in the specified directory
|
|
22
|
+
* 2. Creates a zip archive of all cartridge directories
|
|
23
|
+
* 3. Uploads the zip to WebDAV and triggers server-side unzip
|
|
24
|
+
* 4. Optionally reloads the code version after deploy
|
|
25
|
+
*
|
|
26
|
+
* @param services - MCP services
|
|
27
|
+
* @param injections - Optional dependency injections for testing
|
|
28
|
+
* @returns The cartridge_deploy tool
|
|
29
|
+
*/
|
|
30
|
+
function createCartridgeDeployTool(services, injections) {
|
|
31
|
+
const findAndDeployCartridgesFn = injections?.findAndDeployCartridges || findAndDeployCartridges;
|
|
32
|
+
return createToolAdapter({
|
|
33
|
+
name: 'cartridge_deploy',
|
|
34
|
+
description: 'Finds and deploys cartridges to a B2C Commerce instance via WebDAV. ' +
|
|
35
|
+
'Searches the directory for cartridges (by .project files), applies include/exclude filters, ' +
|
|
36
|
+
'creates a zip archive, uploads via WebDAV, and optionally reloads the code version. ' +
|
|
37
|
+
'Use this tool to deploy custom code cartridges for SFRA or other B2C Commerce code. ' +
|
|
38
|
+
'Requires the instance to have a code version configured.',
|
|
39
|
+
toolsets: ['CARTRIDGES'],
|
|
40
|
+
isGA: false,
|
|
41
|
+
requiresInstance: true,
|
|
42
|
+
inputSchema: {
|
|
43
|
+
directory: z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Path to directory to search for cartridges. Defaults to current working directory if not specified. ' +
|
|
47
|
+
'The tool will recursively search this directory for .project files to identify cartridges.'),
|
|
48
|
+
cartridges: z
|
|
49
|
+
.array(z.string())
|
|
50
|
+
.optional()
|
|
51
|
+
.describe('Array of cartridge names to include in the deployment. If not specified, all cartridges found in the directory are deployed. ' +
|
|
52
|
+
'Use this to selectively deploy specific cartridges when you have multiple cartridges but only want to update some.'),
|
|
53
|
+
exclude: z
|
|
54
|
+
.array(z.string())
|
|
55
|
+
.optional()
|
|
56
|
+
.describe('Array of cartridge names to exclude from the deployment. Use this to skip deploying certain cartridges, ' +
|
|
57
|
+
'such as third-party or unchanged cartridges. Applied after the include filter.'),
|
|
58
|
+
reload: z
|
|
59
|
+
.boolean()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe('Whether to reload (re-activate) the code version after deployment. ' +
|
|
62
|
+
'Set to true to make the deployed code immediately active on the instance. ' +
|
|
63
|
+
'Defaults to false. Use this when you want changes to take effect right away.'),
|
|
64
|
+
},
|
|
65
|
+
async execute(args, context) {
|
|
66
|
+
// Get instance from context (guaranteed by adapter when requiresInstance is true)
|
|
67
|
+
const instance = context.b2cInstance;
|
|
68
|
+
// Default directory to current directory
|
|
69
|
+
const directory = args.directory || '.';
|
|
70
|
+
// Parse options
|
|
71
|
+
const options = {
|
|
72
|
+
include: args.cartridges,
|
|
73
|
+
exclude: args.exclude,
|
|
74
|
+
reload: args.reload,
|
|
75
|
+
};
|
|
76
|
+
// Log all computed variables before deploying
|
|
77
|
+
const logger = getLogger();
|
|
78
|
+
logger.debug({
|
|
79
|
+
directory,
|
|
80
|
+
include: options.include,
|
|
81
|
+
exclude: options.exclude,
|
|
82
|
+
reload: options.reload,
|
|
83
|
+
}, '[Cartridges] Deploying cartridges with computed options');
|
|
84
|
+
// Deploy cartridges
|
|
85
|
+
const result = await findAndDeployCartridgesFn(instance, directory, options);
|
|
86
|
+
return result;
|
|
87
|
+
},
|
|
88
|
+
formatOutput: (output) => jsonResult(output),
|
|
89
|
+
}, services);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Creates all tools for the CARTRIDGES toolset.
|
|
93
|
+
*
|
|
94
|
+
* @param services - MCP services
|
|
95
|
+
* @param injections - Optional dependency injections for testing
|
|
96
|
+
* @returns Array of MCP tools
|
|
97
|
+
*/
|
|
98
|
+
export function createCartridgesTools(services, injections) {
|
|
99
|
+
return [createCartridgeDeployTool(services, injections)];
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools for B2C Commerce developer experience.
|
|
3
|
+
*
|
|
4
|
+
* This module exports all available tools and utilities.
|
|
5
|
+
* Tools use the @salesforce/b2c-tooling-sdk operations layer directly.
|
|
6
|
+
*
|
|
7
|
+
* > ⚠️ **PLACEHOLDER - ACTIVE DEVELOPMENT**
|
|
8
|
+
* > Tools are currently placeholder implementations that return mock responses.
|
|
9
|
+
* > Actual implementations are coming soon. Use `--allow-non-ga-tools` flag to enable.
|
|
10
|
+
*
|
|
11
|
+
* @module tools
|
|
12
|
+
*/
|
|
13
|
+
export * from './adapter.js';
|
|
14
|
+
export * from './cartridges/index.js';
|
|
15
|
+
export * from './mrt/index.js';
|
|
16
|
+
export * from './pwav3/index.js';
|
|
17
|
+
export * from './storefrontnext/index.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* MCP Tools for B2C Commerce developer experience.
|
|
8
|
+
*
|
|
9
|
+
* This module exports all available tools and utilities.
|
|
10
|
+
* Tools use the @salesforce/b2c-tooling-sdk operations layer directly.
|
|
11
|
+
*
|
|
12
|
+
* > ⚠️ **PLACEHOLDER - ACTIVE DEVELOPMENT**
|
|
13
|
+
* > Tools are currently placeholder implementations that return mock responses.
|
|
14
|
+
* > Actual implementations are coming soon. Use `--allow-non-ga-tools` flag to enable.
|
|
15
|
+
*
|
|
16
|
+
* @module tools
|
|
17
|
+
*/
|
|
18
|
+
// Tool adapter utilities
|
|
19
|
+
export * from './adapter.js';
|
|
20
|
+
// Toolset exports
|
|
21
|
+
export * from './cartridges/index.js';
|
|
22
|
+
export * from './mrt/index.js';
|
|
23
|
+
export * from './pwav3/index.js';
|
|
24
|
+
export * from './storefrontnext/index.js';
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { McpTool } from '../../utils/index.js';
|
|
2
|
+
import type { Services } from '../../services.js';
|
|
3
|
+
import type { PushResult, PushOptions } from '@salesforce/b2c-tooling-sdk/operations/mrt';
|
|
4
|
+
import type { AuthStrategy } from '@salesforce/b2c-tooling-sdk/auth';
|
|
5
|
+
/**
|
|
6
|
+
* Optional dependency injections for testing.
|
|
7
|
+
*/
|
|
8
|
+
interface MrtToolInjections {
|
|
9
|
+
/** Mock pushBundle function for testing */
|
|
10
|
+
pushBundle?: (options: PushOptions, auth: AuthStrategy) => Promise<PushResult>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates all tools for the MRT toolset.
|
|
14
|
+
*
|
|
15
|
+
* @param services - MCP services
|
|
16
|
+
* @param injections - Optional dependency injections for testing
|
|
17
|
+
* @returns Array of MCP tools
|
|
18
|
+
*/
|
|
19
|
+
export declare function createMrtTools(services: Services, injections?: MrtToolInjections): McpTool[];
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* MRT (Managed Runtime) toolset for B2C Commerce.
|
|
8
|
+
*
|
|
9
|
+
* This toolset provides MCP tools for Managed Runtime operations.
|
|
10
|
+
*
|
|
11
|
+
* @module tools/mrt
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { createToolAdapter, jsonResult } from '../adapter.js';
|
|
15
|
+
import { pushBundle } from '@salesforce/b2c-tooling-sdk/operations/mrt';
|
|
16
|
+
import { getLogger } from '@salesforce/b2c-tooling-sdk/logging';
|
|
17
|
+
/**
|
|
18
|
+
* Creates the mrt_bundle_push tool.
|
|
19
|
+
*
|
|
20
|
+
* Creates a bundle from a pre-built PWA Kit project and pushes it to
|
|
21
|
+
* Managed Runtime (MRT). Optionally deploys to a target environment after push.
|
|
22
|
+
* Expects the project to already be built (e.g., `npm run build` completed).
|
|
23
|
+
* Shared across MRT, PWAV3, and STOREFRONTNEXT toolsets.
|
|
24
|
+
*
|
|
25
|
+
* @param services - MCP services
|
|
26
|
+
* @param injections - Optional dependency injections for testing
|
|
27
|
+
* @returns The mrt_bundle_push tool
|
|
28
|
+
*/
|
|
29
|
+
function createMrtBundlePushTool(services, injections) {
|
|
30
|
+
const pushBundleFn = injections?.pushBundle || pushBundle;
|
|
31
|
+
return createToolAdapter({
|
|
32
|
+
name: 'mrt_bundle_push',
|
|
33
|
+
description: 'Bundle a pre-built PWA Kit project and push to Managed Runtime. Optionally deploy to a target environment.',
|
|
34
|
+
toolsets: ['MRT', 'PWAV3', 'STOREFRONTNEXT'],
|
|
35
|
+
isGA: false,
|
|
36
|
+
// MRT operations use ApiKeyStrategy from SFCC_MRT_API_KEY or ~/.mobify
|
|
37
|
+
requiresMrtAuth: true,
|
|
38
|
+
inputSchema: {
|
|
39
|
+
buildDirectory: z.string().optional().describe('Path to build directory (default: ./build)'),
|
|
40
|
+
message: z.string().optional().describe('Deployment message'),
|
|
41
|
+
ssrOnly: z
|
|
42
|
+
.string()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe('Glob patterns for server-only files, comma-separated (default: ssr.js,ssr.mjs,server/**/*)'),
|
|
45
|
+
ssrShared: z
|
|
46
|
+
.string()
|
|
47
|
+
.optional()
|
|
48
|
+
.describe('Glob patterns for shared files, comma-separated (default: static/**/*,client/**/*)'),
|
|
49
|
+
},
|
|
50
|
+
async execute(args, context) {
|
|
51
|
+
// Get project from --project flag (required)
|
|
52
|
+
const project = context.mrtConfig?.project;
|
|
53
|
+
if (!project) {
|
|
54
|
+
throw new Error('MRT project error: Project is required. Provide --project flag or set SFCC_MRT_PROJECT environment variable.');
|
|
55
|
+
}
|
|
56
|
+
// Get environment from --environment flag (optional)
|
|
57
|
+
const environment = context.mrtConfig?.environment;
|
|
58
|
+
// Get origin from --cloud-origin flag or mrtOrigin config (optional)
|
|
59
|
+
const origin = context.mrtConfig?.origin;
|
|
60
|
+
// Parse comma-separated glob patterns (same as CLI defaults)
|
|
61
|
+
const ssrOnly = (args.ssrOnly || 'ssr.js,ssr.mjs,server/**/*').split(',').map((s) => s.trim());
|
|
62
|
+
const ssrShared = (args.ssrShared || 'static/**/*,client/**/*').split(',').map((s) => s.trim());
|
|
63
|
+
const buildDirectory = args.buildDirectory || './build';
|
|
64
|
+
// Log all computed variables before pushing bundle
|
|
65
|
+
const logger = getLogger();
|
|
66
|
+
logger.debug({
|
|
67
|
+
project,
|
|
68
|
+
environment,
|
|
69
|
+
origin,
|
|
70
|
+
buildDirectory,
|
|
71
|
+
message: args.message,
|
|
72
|
+
ssrOnly,
|
|
73
|
+
ssrShared,
|
|
74
|
+
}, '[MRT] Pushing bundle with computed options');
|
|
75
|
+
// Push bundle to MRT
|
|
76
|
+
// Note: auth is guaranteed to be present by the adapter when requiresMrtAuth is true
|
|
77
|
+
const result = await pushBundleFn({
|
|
78
|
+
projectSlug: project,
|
|
79
|
+
buildDirectory,
|
|
80
|
+
ssrOnly, // files that run only on SSR server (never sent to browser)
|
|
81
|
+
ssrShared, // files served from CDN and also available to SSR
|
|
82
|
+
message: args.message,
|
|
83
|
+
target: environment,
|
|
84
|
+
origin, // MRT API origin URL (optional, defaults to https://cloud.mobify.com)
|
|
85
|
+
}, context.mrtConfig.auth);
|
|
86
|
+
return result;
|
|
87
|
+
},
|
|
88
|
+
formatOutput: (output) => jsonResult(output),
|
|
89
|
+
}, services);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Creates all tools for the MRT toolset.
|
|
93
|
+
*
|
|
94
|
+
* @param services - MCP services
|
|
95
|
+
* @param injections - Optional dependency injections for testing
|
|
96
|
+
* @returns Array of MCP tools
|
|
97
|
+
*/
|
|
98
|
+
export function createMrtTools(services, injections) {
|
|
99
|
+
return [createMrtBundlePushTool(services, injections)];
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { McpTool } from '../../utils/index.js';
|
|
2
|
+
import type { Services } from '../../services.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates all tools for the PWAV3 toolset.
|
|
5
|
+
*
|
|
6
|
+
* Note: mrt_bundle_push is defined in the MRT toolset with
|
|
7
|
+
* toolsets: ["MRT", "PWAV3", "STOREFRONTNEXT"] and will
|
|
8
|
+
* automatically appear in PWAV3.
|
|
9
|
+
*
|
|
10
|
+
* @param services - MCP services
|
|
11
|
+
* @returns Array of MCP tools
|
|
12
|
+
*/
|
|
13
|
+
export declare function createPwav3Tools(services: Services): McpTool[];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* PWA Kit v3 toolset for B2C Commerce.
|
|
8
|
+
*
|
|
9
|
+
* This toolset provides MCP tools for PWA Kit v3 development.
|
|
10
|
+
*
|
|
11
|
+
* > ⚠️ **PLACEHOLDER - ACTIVE DEVELOPMENT**
|
|
12
|
+
* > Tools in this module are placeholder implementations that return mock responses.
|
|
13
|
+
* > Actual implementations are coming soon. Use `--allow-non-ga-tools` flag to enable.
|
|
14
|
+
*
|
|
15
|
+
* @module tools/pwav3
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import { createToolAdapter, jsonResult } from '../adapter.js';
|
|
19
|
+
/**
|
|
20
|
+
* Creates a placeholder tool for PWA Kit development.
|
|
21
|
+
*
|
|
22
|
+
* Placeholder tools log invocations and return mock responses until
|
|
23
|
+
* the actual implementation is available.
|
|
24
|
+
*
|
|
25
|
+
* @param name - Tool name
|
|
26
|
+
* @param description - Tool description
|
|
27
|
+
* @param toolsets - Toolsets this tool belongs to
|
|
28
|
+
* @param services - MCP services
|
|
29
|
+
* @returns The configured MCP tool
|
|
30
|
+
*/
|
|
31
|
+
function createPlaceholderTool(name, description, toolsets, services) {
|
|
32
|
+
return createToolAdapter({
|
|
33
|
+
name,
|
|
34
|
+
description: `[PLACEHOLDER] ${description}`,
|
|
35
|
+
toolsets,
|
|
36
|
+
isGA: false,
|
|
37
|
+
requiresInstance: false,
|
|
38
|
+
inputSchema: {
|
|
39
|
+
message: z.string().optional().describe('Optional message to echo'),
|
|
40
|
+
},
|
|
41
|
+
async execute(args) {
|
|
42
|
+
// Placeholder implementation
|
|
43
|
+
const timestamp = new Date().toISOString();
|
|
44
|
+
return {
|
|
45
|
+
tool: name,
|
|
46
|
+
status: 'placeholder',
|
|
47
|
+
message: `This is a placeholder implementation for '${name}'. The actual implementation is coming soon.`,
|
|
48
|
+
input: args,
|
|
49
|
+
timestamp,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
formatOutput: (output) => jsonResult(output),
|
|
53
|
+
}, services);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates all tools for the PWAV3 toolset.
|
|
57
|
+
*
|
|
58
|
+
* Note: mrt_bundle_push is defined in the MRT toolset with
|
|
59
|
+
* toolsets: ["MRT", "PWAV3", "STOREFRONTNEXT"] and will
|
|
60
|
+
* automatically appear in PWAV3.
|
|
61
|
+
*
|
|
62
|
+
* @param services - MCP services
|
|
63
|
+
* @returns Array of MCP tools
|
|
64
|
+
*/
|
|
65
|
+
export function createPwav3Tools(services) {
|
|
66
|
+
return [
|
|
67
|
+
// PWA Kit development tools
|
|
68
|
+
createPlaceholderTool('pwakit_create_storefront', 'Create a new PWA Kit storefront project', ['PWAV3'], services),
|
|
69
|
+
createPlaceholderTool('pwakit_create_page', 'Create a new page component in PWA Kit project', ['PWAV3'], services),
|
|
70
|
+
createPlaceholderTool('pwakit_create_component', 'Create a new React component in PWA Kit project', ['PWAV3'], services),
|
|
71
|
+
createPlaceholderTool('pwakit_get_dev_guidelines', 'Get PWA Kit development guidelines and best practices', ['PWAV3'], services),
|
|
72
|
+
createPlaceholderTool('pwakit_recommend_hooks', 'Recommend appropriate React hooks for PWA Kit use cases', ['PWAV3'], services),
|
|
73
|
+
createPlaceholderTool('pwakit_run_site_test', 'Run site tests for PWA Kit project', ['PWAV3'], services),
|
|
74
|
+
createPlaceholderTool('pwakit_install_agent_rules', 'Install AI agent rules for PWA Kit development', ['PWAV3'], services),
|
|
75
|
+
createPlaceholderTool('pwakit_explore_scapi_shop_api', 'Explore SCAPI Shop API endpoints and capabilities', ['PWAV3'], services),
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { McpTool } from '../../utils/index.js';
|
|
2
|
+
import type { Services } from '../../services.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates all tools for the SCAPI toolset.
|
|
5
|
+
*
|
|
6
|
+
* @param services - MCP services
|
|
7
|
+
* @returns Array of MCP tools
|
|
8
|
+
*/
|
|
9
|
+
export declare function createScapiTools(services: Services): McpTool[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* SCAPI toolset for B2C Commerce.
|
|
8
|
+
*
|
|
9
|
+
* This toolset provides MCP tools for Salesforce Commerce API (SCAPI) discovery and exploration.
|
|
10
|
+
*
|
|
11
|
+
* > ⚠️ **PLACEHOLDER - ACTIVE DEVELOPMENT**
|
|
12
|
+
* > Tools in this module are placeholder implementations that return mock responses.
|
|
13
|
+
* > Actual implementations are coming soon. Use `--allow-non-ga-tools` flag to enable.
|
|
14
|
+
*
|
|
15
|
+
* @module tools/scapi
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import { createToolAdapter, jsonResult } from '../adapter.js';
|
|
19
|
+
/**
|
|
20
|
+
* Creates a placeholder tool for SCAPI operations.
|
|
21
|
+
*
|
|
22
|
+
* Placeholder tools log invocations and return mock responses until
|
|
23
|
+
* the actual implementation is available.
|
|
24
|
+
*
|
|
25
|
+
* @param name - Tool name
|
|
26
|
+
* @param description - Tool description
|
|
27
|
+
* @param toolsets - Toolsets this tool belongs to
|
|
28
|
+
* @param services - MCP services
|
|
29
|
+
* @returns The configured MCP tool
|
|
30
|
+
*/
|
|
31
|
+
function createPlaceholderTool(name, description, toolsets, services) {
|
|
32
|
+
return createToolAdapter({
|
|
33
|
+
name,
|
|
34
|
+
description: `[PLACEHOLDER] ${description}`,
|
|
35
|
+
toolsets,
|
|
36
|
+
isGA: false,
|
|
37
|
+
requiresInstance: true,
|
|
38
|
+
inputSchema: {
|
|
39
|
+
message: z.string().optional().describe('Optional message to echo'),
|
|
40
|
+
},
|
|
41
|
+
async execute(args) {
|
|
42
|
+
// Placeholder implementation
|
|
43
|
+
const timestamp = new Date().toISOString();
|
|
44
|
+
return {
|
|
45
|
+
tool: name,
|
|
46
|
+
status: 'placeholder',
|
|
47
|
+
message: `This is a placeholder implementation for '${name}'. The actual implementation is coming soon.`,
|
|
48
|
+
input: args,
|
|
49
|
+
timestamp,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
formatOutput: (output) => jsonResult(output),
|
|
53
|
+
}, services);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates all tools for the SCAPI toolset.
|
|
57
|
+
*
|
|
58
|
+
* @param services - MCP services
|
|
59
|
+
* @returns Array of MCP tools
|
|
60
|
+
*/
|
|
61
|
+
export function createScapiTools(services) {
|
|
62
|
+
return [
|
|
63
|
+
createPlaceholderTool('scapi_discovery', 'Discover available SCAPI endpoints and capabilities', ['PWAV3', 'SCAPI', 'STOREFRONTNEXT'], services),
|
|
64
|
+
createPlaceholderTool('scapi_customapi_scaffold', 'Scaffold a new custom SCAPI API', ['SCAPI'], services),
|
|
65
|
+
createPlaceholderTool('scapi_custom_api_discovery', 'Discover custom SCAPI API endpoints', ['PWAV3', 'SCAPI', 'STOREFRONTNEXT'], services),
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { McpTool } from '../../utils/index.js';
|
|
2
|
+
import type { Services } from '../../services.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the developer guidelines tool for Storefront Next.
|
|
5
|
+
*
|
|
6
|
+
* @param services - MCP services
|
|
7
|
+
* @returns The configured MCP tool
|
|
8
|
+
*/
|
|
9
|
+
export declare function createDeveloperGuidelinesTool(services: Services): McpTool;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Developer Guidelines tool for Storefront Next.
|
|
8
|
+
*
|
|
9
|
+
* Provides critical development guidelines and best practices for building
|
|
10
|
+
* Storefront Next applications with React Server Components.
|
|
11
|
+
*
|
|
12
|
+
* @module tools/storefrontnext/developer-guidelines
|
|
13
|
+
*/
|
|
14
|
+
import { readFileSync } from 'node:fs';
|
|
15
|
+
import { createRequire } from 'node:module';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import { createToolAdapter, textResult } from '../adapter.js';
|
|
19
|
+
// Resolve the content directory from the package root
|
|
20
|
+
// Uses createRequire to find the package.json location, which is robust
|
|
21
|
+
// regardless of where this module is located in the build output
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
const packageRoot = path.dirname(require.resolve('@salesforce/b2c-dx-mcp/package.json'));
|
|
24
|
+
const CONTENT_DIR = path.join(packageRoot, 'content');
|
|
25
|
+
/**
|
|
26
|
+
* Section metadata with key and optional description.
|
|
27
|
+
* Single source of truth for all available sections.
|
|
28
|
+
*/
|
|
29
|
+
const SECTIONS_METADATA = [
|
|
30
|
+
{ key: 'quick-reference', description: null }, // Meta-section, excluded from topics list
|
|
31
|
+
{
|
|
32
|
+
key: 'data-fetching',
|
|
33
|
+
description: 'server-only data loading (no client loaders), synchronous loaders for streaming, data fetching patterns',
|
|
34
|
+
},
|
|
35
|
+
{ key: 'state-management', description: 'state management patterns' },
|
|
36
|
+
{ key: 'auth', description: 'authentication and session management' },
|
|
37
|
+
{ key: 'config', description: 'configuration' },
|
|
38
|
+
{ key: 'i18n', description: 'i18n patterns and internationalization' },
|
|
39
|
+
{ key: 'components', description: 'component best practices' },
|
|
40
|
+
{ key: 'styling', description: 'Tailwind CSS 4, Shadcn/ui, styling guidelines' },
|
|
41
|
+
{ key: 'page-designer', description: 'Page Designer integration' },
|
|
42
|
+
{ key: 'performance', description: 'performance optimization' },
|
|
43
|
+
{ key: 'testing', description: 'testing strategies' },
|
|
44
|
+
{ key: 'extensions', description: 'framework extensions' },
|
|
45
|
+
{ key: 'pitfalls', description: 'common pitfalls' },
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Derived: array of section keys for validation.
|
|
49
|
+
*/
|
|
50
|
+
const _SECTIONS = SECTIONS_METADATA.map((s) => s.key);
|
|
51
|
+
/**
|
|
52
|
+
* Generates the topics list for the tool description.
|
|
53
|
+
* Excludes meta-sections (like quick-reference) that don't have descriptions.
|
|
54
|
+
* @returns Comma-separated list of topics
|
|
55
|
+
*/
|
|
56
|
+
function generateTopicsList() {
|
|
57
|
+
return SECTIONS_METADATA.filter((s) => s.description !== null)
|
|
58
|
+
.map((s) => s.description)
|
|
59
|
+
.join(', ');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Detailed section content loaded from markdown files.
|
|
63
|
+
* Built dynamically from SECTIONS_METADATA to avoid duplication.
|
|
64
|
+
*/
|
|
65
|
+
const SECTION_CONTENT = Object.fromEntries(SECTIONS_METADATA.map((section) => {
|
|
66
|
+
const filename = `${section.key}.md`;
|
|
67
|
+
const filePath = path.join(CONTENT_DIR, filename);
|
|
68
|
+
const content = readFileSync(filePath, 'utf8');
|
|
69
|
+
return [section.key, content];
|
|
70
|
+
}));
|
|
71
|
+
/**
|
|
72
|
+
* Default sections to return when no sections are specified.
|
|
73
|
+
* Includes quick-reference plus the most critical detailed sections
|
|
74
|
+
* to provide comprehensive guidelines by default.
|
|
75
|
+
*/
|
|
76
|
+
const DEFAULT_SECTIONS = ['quick-reference', 'data-fetching', 'components', 'testing'];
|
|
77
|
+
/**
|
|
78
|
+
* Creates the developer guidelines tool for Storefront Next.
|
|
79
|
+
*
|
|
80
|
+
* @param services - MCP services
|
|
81
|
+
* @returns The configured MCP tool
|
|
82
|
+
*/
|
|
83
|
+
export function createDeveloperGuidelinesTool(services) {
|
|
84
|
+
return createToolAdapter({
|
|
85
|
+
name: 'storefront_next_development_guidelines',
|
|
86
|
+
description: 'ESSENTIAL FIRST STEP for Storefront Next development. Returns critical architecture rules, coding standards, and best practices. ' +
|
|
87
|
+
'Use this tool FIRST before writing any Storefront Next code to understand non-negotiable patterns for React Server Components, ' +
|
|
88
|
+
'data loading, and framework constraints. Returns comprehensive guidelines by default (quick-reference + key sections); ' +
|
|
89
|
+
'supports retrieving specific topic sections. ' +
|
|
90
|
+
'CRITICAL INSTRUCTION: ALWAYS present ALL returned content in FULL - DO NOT SUMMARIZE, DO NOT ADD SUMMARIES, ' +
|
|
91
|
+
'DO NOT ADD OVERVIEWS. The returned content IS the complete answer - display it exactly as provided.',
|
|
92
|
+
toolsets: ['STOREFRONTNEXT'],
|
|
93
|
+
isGA: false,
|
|
94
|
+
requiresInstance: false,
|
|
95
|
+
inputSchema: {
|
|
96
|
+
sections: z
|
|
97
|
+
.array(z.enum([..._SECTIONS]))
|
|
98
|
+
.optional()
|
|
99
|
+
.describe('Optional array of specific sections to retrieve. If not specified, returns comprehensive guidelines ' +
|
|
100
|
+
'(quick-reference, data-fetching, components, testing). ' +
|
|
101
|
+
'CRITICAL: Present ALL returned content in FULL - DO NOT SUMMARIZE. ' +
|
|
102
|
+
'Available sections: quick-reference, data-fetching, state-management, auth, config, i18n, ' +
|
|
103
|
+
'components, page-designer, performance, testing, extensions, pitfalls. ' +
|
|
104
|
+
`Topics covered: ${generateTopicsList()}. ` +
|
|
105
|
+
'Content is complete - present exactly as provided, no summaries.'),
|
|
106
|
+
},
|
|
107
|
+
async execute(args) {
|
|
108
|
+
// Handle empty array case explicitly
|
|
109
|
+
if (args.sections && args.sections.length === 0) {
|
|
110
|
+
return '';
|
|
111
|
+
}
|
|
112
|
+
// Default to comprehensive set of key sections if no sections specified
|
|
113
|
+
const sections = args.sections || DEFAULT_SECTIONS;
|
|
114
|
+
// Multiple sections: combine with separators
|
|
115
|
+
const combinedContent = sections.map((section) => SECTION_CONTENT[section]).join('\n\n---\n\n');
|
|
116
|
+
// Apply instructions for all multi-section responses to ensure full content display
|
|
117
|
+
// Single sections are typically smaller and don't need heavy instructions
|
|
118
|
+
const isMultiSection = sections.length > 1;
|
|
119
|
+
// Prepend explicit instruction to present full content (not summarized)
|
|
120
|
+
// This helps AI assistants understand they should show the complete guidelines without summarization
|
|
121
|
+
const fullContentInstruction = isMultiSection
|
|
122
|
+
? '⚠️ CRITICAL: Display the FULL content below. DO NOT summarize, condense, or add overviews.\n\n' +
|
|
123
|
+
'📋 STOREFRONT NEXT DEVELOPMENT GUIDELINES\n\n' +
|
|
124
|
+
'---\n\n'
|
|
125
|
+
: '';
|
|
126
|
+
// Add footer instruction to reinforce the message for multi-section responses
|
|
127
|
+
const footerInstruction = isMultiSection
|
|
128
|
+
? '\n\n---\n\n⚠️ END OF CONTENT - Full content displayed above. Do not add summaries.\n'
|
|
129
|
+
: '';
|
|
130
|
+
// For single sections, return directly (backward compatible)
|
|
131
|
+
// For multiple sections, wrap with instructions
|
|
132
|
+
if (sections.length === 1) {
|
|
133
|
+
return SECTION_CONTENT[sections[0]];
|
|
134
|
+
}
|
|
135
|
+
return fullContentInstruction + combinedContent + footerInstruction;
|
|
136
|
+
},
|
|
137
|
+
formatOutput: (output) => textResult(output),
|
|
138
|
+
}, services);
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=developer-guidelines.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { McpTool } from '../../utils/index.js';
|
|
2
|
+
import type { Services } from '../../services.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates all tools for the STOREFRONTNEXT toolset.
|
|
5
|
+
*
|
|
6
|
+
* Note: mrt_bundle_push is defined in the MRT toolset with
|
|
7
|
+
* toolsets: ["MRT", "PWAV3", "STOREFRONTNEXT"] and will
|
|
8
|
+
* automatically appear in STOREFRONTNEXT.
|
|
9
|
+
*
|
|
10
|
+
* @param services - MCP services
|
|
11
|
+
* @returns Array of MCP tools
|
|
12
|
+
*/
|
|
13
|
+
export declare function createStorefrontNextTools(services: Services): McpTool[];
|