@salesforce/b2c-dx-mcp 0.4.2 → 0.4.4
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 +20 -20
- package/dist/commands/mcp.js +4 -4
- package/dist/registry.js +7 -7
- package/dist/services.d.ts +2 -2
- package/dist/services.js +3 -3
- package/dist/tools/cartridges/index.js +2 -2
- package/dist/tools/storefrontnext/page-designer-decorator/index.js +2 -2
- package/dist/utils/types.d.ts +2 -2
- package/oclif.manifest.json +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Salesforce Commerce
|
|
1
|
+
# Salesforce B2C Commerce MCP Server
|
|
2
2
|
|
|
3
|
-
MCP (Model Context Protocol) server for Salesforce B2C Commerce
|
|
3
|
+
MCP (Model Context Protocol) server for Salesforce B2C Commerce developer experience tools.
|
|
4
4
|
|
|
5
|
-
> ⚠️ **Active Development**: This package is under active development.
|
|
5
|
+
> ⚠️ **Active Development**: This package is under active development. Some tools are currently **placeholder implementations** that return mock responses. Tool implementations will be added incrementally.
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
|
@@ -12,15 +12,15 @@ The server automatically detects your project type and enables relevant tools. S
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Project Directory and Auto-Discovery
|
|
16
16
|
|
|
17
|
-
The most important flag is **`--
|
|
17
|
+
The most important flag is **`--project-directory`** (or env var `SFCC_PROJECT_DIRECTORY`). It tells the server where your project is located, enabling:
|
|
18
18
|
|
|
19
19
|
1. **Auto-discovery** - Detects your project type and enables appropriate toolsets
|
|
20
20
|
2. **Configuration loading** - Reads [`dw.json`](https://salesforcecommercecloud.github.io/b2c-developer-tooling/guide/configuration.html#configuration-file) from your project for credentials
|
|
21
21
|
3. **Scaffolding** - Creates new files in the correct location
|
|
22
22
|
|
|
23
|
-
> **Important:** MCP clients like Cursor and Claude Desktop spawn servers from the home directory (`~`), not your project. Always set `--
|
|
23
|
+
> **Important:** MCP clients like Cursor and Claude Desktop spawn servers from the home directory (`~`), not your project. Always set `--project-directory`.
|
|
24
24
|
|
|
25
25
|
**Cursor** (supports `${workspaceFolder}`):
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ The most important flag is **`--working-directory`** (or env var `SFCC_WORKING_D
|
|
|
29
29
|
"mcpServers": {
|
|
30
30
|
"b2c-dx": {
|
|
31
31
|
"command": "npx",
|
|
32
|
-
"args": ["-y", "@salesforce/b2c-dx-mcp", "--
|
|
32
|
+
"args": ["-y", "@salesforce/b2c-dx-mcp", "--project-directory", "${workspaceFolder}", "--allow-non-ga-tools"]
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -42,7 +42,7 @@ The most important flag is **`--working-directory`** (or env var `SFCC_WORKING_D
|
|
|
42
42
|
"mcpServers": {
|
|
43
43
|
"b2c-dx": {
|
|
44
44
|
"command": "npx",
|
|
45
|
-
"args": ["-y", "@salesforce/b2c-dx-mcp", "--
|
|
45
|
+
"args": ["-y", "@salesforce/b2c-dx-mcp", "--project-directory", "/path/to/your/project", "--allow-non-ga-tools"]
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -50,7 +50,7 @@ The most important flag is **`--working-directory`** (or env var `SFCC_WORKING_D
|
|
|
50
50
|
|
|
51
51
|
### Project Type Detection
|
|
52
52
|
|
|
53
|
-
The server analyzes your
|
|
53
|
+
The server analyzes your project directory and enables toolsets based on what it finds:
|
|
54
54
|
|
|
55
55
|
| Project Type | Detection | Toolsets Enabled |
|
|
56
56
|
|--------------|-----------|------------------|
|
|
@@ -66,14 +66,14 @@ The **SCAPI** toolset is always enabled. Hybrid projects (e.g., cartridges + PWA
|
|
|
66
66
|
Override auto-discovery by specifying toolsets explicitly:
|
|
67
67
|
|
|
68
68
|
```json
|
|
69
|
-
"args": ["--
|
|
69
|
+
"args": ["--project-directory", "${workspaceFolder}", "--toolsets", "CARTRIDGES,MRT", "--allow-non-ga-tools"]
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
### Prompting Tips and Examples
|
|
73
73
|
|
|
74
74
|
AI assistants (like Cursor, Claude Desktop) automatically decide which MCP tools to use based on your prompts. To get the best results, use clear, specific prompts that describe what you want to accomplish.
|
|
75
75
|
|
|
76
|
-
> ⚠️ **IMPORTANT**: **Explicitly mention "Use the MCP tool"** in your prompts for reliable tool usage. While AI assistants (like Cursor's Composer) can automatically select MCP tools based on context, explicit instructions ensure the assistant prioritizes MCP tools over general knowledge, especially when multiple approaches are possible. This is particularly important for getting project-specific, up-to-date information rather than generic responses.
|
|
76
|
+
> ⚠️ **IMPORTANT**: **Explicitly mention "Use the MCP tool"** in your prompts for reliable tool usage. While AI assistants (like Cursor's Composer) can automatically select MCP tools based on context, explicit instructions ensure that the assistant prioritizes MCP tools over general knowledge, especially when multiple approaches are possible. This is particularly important for getting project-specific, up-to-date information rather than generic responses.
|
|
77
77
|
|
|
78
78
|
#### Best Practices
|
|
79
79
|
|
|
@@ -90,7 +90,7 @@ AI assistants (like Cursor, Claude Desktop) automatically decide which MCP tools
|
|
|
90
90
|
|
|
91
91
|
The `storefront_next_development_guidelines` tool provides critical architecture rules and best practices. **Use this tool first** when starting new Storefront Next development or when you need architecture guidance.
|
|
92
92
|
|
|
93
|
-
**
|
|
93
|
+
**Prompt examples:**
|
|
94
94
|
- ✅ "I'm new to Storefront Next. Use the MCP tool to show me the critical rules I need to know."
|
|
95
95
|
- ✅ "I need to build a product detail page. Use the MCP tool to show me best practices for data fetching and component patterns."
|
|
96
96
|
- ✅ "I need to build a checkout form with authentication and validation. Use the MCP tool to show me how to handle form submissions, authentication, and internationalized error messages."
|
|
@@ -114,7 +114,7 @@ The `storefront_next_development_guidelines` tool provides critical architecture
|
|
|
114
114
|
|
|
115
115
|
##### PWA Kit Development
|
|
116
116
|
|
|
117
|
-
**
|
|
117
|
+
**Prompt examples:**
|
|
118
118
|
- ✅ "I'm starting a new PWA Kit project. Use the MCP tool to get the development guidelines."
|
|
119
119
|
- ✅ "Use the MCP tool to create a new product listing page component in my PWA Kit project."
|
|
120
120
|
- ✅ "Use the MCP tool to recommend React hooks for fetching product data in PWA Kit."
|
|
@@ -153,14 +153,14 @@ Get registration status of custom API endpoints deployed on the instance (remote
|
|
|
153
153
|
|
|
154
154
|
##### Cartridge Deployment
|
|
155
155
|
|
|
156
|
-
**
|
|
156
|
+
**Prompt examples:**
|
|
157
157
|
- ✅ "Use the MCP tool to deploy my cartridges to the sandbox instance."
|
|
158
158
|
- ✅ "Use the MCP tool to deploy only the app_storefront_base cartridge to production."
|
|
159
159
|
- ✅ "Use the MCP tool to deploy cartridges from the ./cartridges directory and reload the code version."
|
|
160
160
|
|
|
161
161
|
##### MRT Bundle Operations
|
|
162
162
|
|
|
163
|
-
**
|
|
163
|
+
**Prompt examples:**
|
|
164
164
|
- ✅ "Use the MCP tool to build and push my Storefront Next bundle to staging."
|
|
165
165
|
- ✅ "Use the MCP tool to push the bundle from ./build directory to Managed Runtime."
|
|
166
166
|
- ✅ "Use the MCP tool to deploy my PWA Kit or Storefront Next bundle to production with a deployment message."
|
|
@@ -181,8 +181,8 @@ Credentials can be provided via **config files** (recommended), **environment va
|
|
|
181
181
|
| **SCAPI** | `hostname` + `client-id` + `client-secret` (for `scapi_custom_apis_status`: requires `sfcc.custom-apis` scope) |
|
|
182
182
|
| **CARTRIDGES** | `hostname` + `username` + `password` (or OAuth) |
|
|
183
183
|
| **MRT** | `api-key` + `project` (optionally `environment`) |
|
|
184
|
-
| **PWAV3** | `--
|
|
185
|
-
| **STOREFRONTNEXT** | `--
|
|
184
|
+
| **PWAV3** | `--project-directory` only (+ MRT config for deployments) |
|
|
185
|
+
| **STOREFRONTNEXT** | `--project-directory` only (+ MRT/CARTRIDGES config for those tools) |
|
|
186
186
|
|
|
187
187
|
**Option 1: Config files (recommended)**
|
|
188
188
|
|
|
@@ -220,7 +220,7 @@ See [Flag Reference](#flag-reference) for all available flags and env vars.
|
|
|
220
220
|
|
|
221
221
|
| Flag | Env Variable | Description |
|
|
222
222
|
|------|--------------|-------------|
|
|
223
|
-
| `--
|
|
223
|
+
| `--project-directory` | `SFCC_PROJECT_DIRECTORY` | Project directory (enables auto-discovery and config loading) |
|
|
224
224
|
| `--toolsets` | — | Comma-separated toolsets to enable |
|
|
225
225
|
| `--tools` | — | Comma-separated individual tools to enable |
|
|
226
226
|
| `--allow-non-ga-tools` | — | Enable experimental (non-GA) tools |
|
|
@@ -378,7 +378,7 @@ pnpm run lint
|
|
|
378
378
|
pnpm run clean
|
|
379
379
|
```
|
|
380
380
|
|
|
381
|
-
###
|
|
381
|
+
### Project Directory
|
|
382
382
|
|
|
383
383
|
Commands should be run from the `packages/b2c-dx-mcp` directory:
|
|
384
384
|
|
|
@@ -435,7 +435,7 @@ Configure your IDE to use the local MCP server. Add this to your IDE's MCP confi
|
|
|
435
435
|
}
|
|
436
436
|
```
|
|
437
437
|
|
|
438
|
-
> **Note:** Make sure the script is executable: `chmod +x /full/path/to/packages/b2c-dx-mcp/bin/dev.js`
|
|
438
|
+
> **Note:** Make sure that the script is executable: `chmod +x /full/path/to/packages/b2c-dx-mcp/bin/dev.js`
|
|
439
439
|
>
|
|
440
440
|
> The script's shebang (`#!/usr/bin/env -S node --conditions development`) handles Node.js setup automatically.
|
|
441
441
|
|
package/dist/commands/mcp.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* MCP Server Command - Salesforce B2C Commerce Developer Experience
|
|
8
8
|
*
|
|
9
9
|
* This is the main entry point for the B2C DX MCP server, built with oclif.
|
|
10
|
-
* It exposes B2C Commerce
|
|
10
|
+
* It exposes B2C Commerce developer tools to AI assistants via the
|
|
11
11
|
* Model Context Protocol (MCP).
|
|
12
12
|
*
|
|
13
13
|
* ## Flags
|
|
@@ -151,7 +151,7 @@ import { TOOLSETS } from '../utils/index.js';
|
|
|
151
151
|
* - `this.config` - package.json metadata and standard config paths
|
|
152
152
|
*/
|
|
153
153
|
export default class McpServerCommand extends BaseCommand {
|
|
154
|
-
static description = 'Salesforce B2C Commerce
|
|
154
|
+
static description = 'Salesforce B2C Commerce Developer Experience MCP Server - Expose B2C Commerce Developer Experience tools to AI assistants';
|
|
155
155
|
static examples = [
|
|
156
156
|
{
|
|
157
157
|
description: 'All toolsets',
|
|
@@ -297,8 +297,8 @@ export default class McpServerCommand extends BaseCommand {
|
|
|
297
297
|
tools: this.flags.tools ? this.flags.tools.split(',').map((s) => s.trim()) : undefined,
|
|
298
298
|
allowNonGaTools: this.flags['allow-non-ga-tools'],
|
|
299
299
|
configPath: this.flags.config,
|
|
300
|
-
//
|
|
301
|
-
|
|
300
|
+
// Project directory for auto-discovery. oclif handles flag with env fallback.
|
|
301
|
+
projectDirectory: this.flags['project-directory'],
|
|
302
302
|
};
|
|
303
303
|
// Add toolsets to telemetry attributes
|
|
304
304
|
if (this.telemetry && startupFlags.toolsets) {
|
package/dist/registry.js
CHANGED
|
@@ -89,21 +89,21 @@ export function createToolRegistry(loadServices) {
|
|
|
89
89
|
* Performs workspace auto-discovery and returns appropriate toolsets.
|
|
90
90
|
* Always includes BASE_TOOLSET even if no project types are detected.
|
|
91
91
|
*
|
|
92
|
-
* @param flags - Startup flags containing
|
|
92
|
+
* @param flags - Startup flags containing projectDirectory
|
|
93
93
|
* @param reason - Reason for triggering auto-discovery (for logging)
|
|
94
94
|
* @returns Array of toolsets to enable
|
|
95
95
|
*/
|
|
96
96
|
async function performAutoDiscovery(flags, reason) {
|
|
97
97
|
const logger = getLogger();
|
|
98
|
-
//
|
|
99
|
-
const
|
|
100
|
-
// Warn if
|
|
101
|
-
if (!flags.
|
|
102
|
-
logger.warn({ cwd:
|
|
98
|
+
// Project directory from --project-directory flag or SFCC_PROJECT_DIRECTORY env var
|
|
99
|
+
const projectDirectory = flags.projectDirectory ?? process.cwd();
|
|
100
|
+
// Warn if project directory wasn't explicitly configured
|
|
101
|
+
if (!flags.projectDirectory) {
|
|
102
|
+
logger.warn({ cwd: projectDirectory }, 'No --project-directory flag or SFCC_PROJECT_DIRECTORY env var provided. ' +
|
|
103
103
|
'MCP clients like Cursor and Claude Desktop often spawn servers from ~ instead of the project directory. ' +
|
|
104
104
|
'Set --project-directory or SFCC_PROJECT_DIRECTORY for reliable auto-discovery.');
|
|
105
105
|
}
|
|
106
|
-
const detectionResult = await detectWorkspaceType(
|
|
106
|
+
const detectionResult = await detectWorkspaceType(projectDirectory);
|
|
107
107
|
// Map all detected project types to MCP toolsets (union)
|
|
108
108
|
// Note: getToolsetsForProjectTypes always includes BASE_TOOLSET
|
|
109
109
|
const mappedToolsets = getToolsetsForProjectTypes(detectionResult.projectTypes);
|
package/dist/services.d.ts
CHANGED
|
@@ -185,13 +185,13 @@ export declare class Services {
|
|
|
185
185
|
*/
|
|
186
186
|
getWebDavClient(): WebDavClient;
|
|
187
187
|
/**
|
|
188
|
-
* Get the project
|
|
188
|
+
* Get the project project directory.
|
|
189
189
|
* Falls back to process.cwd() if not explicitly set.
|
|
190
190
|
*
|
|
191
191
|
* This is the directory where the project is located, which may differ from process.cwd()
|
|
192
192
|
* when MCP clients spawn servers from a different location (e.g., home directory).
|
|
193
193
|
*
|
|
194
|
-
* @returns Project
|
|
194
|
+
* @returns Project project directory path
|
|
195
195
|
*/
|
|
196
196
|
getWorkingDirectory(): string;
|
|
197
197
|
/**
|
package/dist/services.js
CHANGED
|
@@ -234,16 +234,16 @@ export class Services {
|
|
|
234
234
|
return this.b2cInstance.webdav;
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
237
|
-
* Get the project
|
|
237
|
+
* Get the project project directory.
|
|
238
238
|
* Falls back to process.cwd() if not explicitly set.
|
|
239
239
|
*
|
|
240
240
|
* This is the directory where the project is located, which may differ from process.cwd()
|
|
241
241
|
* when MCP clients spawn servers from a different location (e.g., home directory).
|
|
242
242
|
*
|
|
243
|
-
* @returns Project
|
|
243
|
+
* @returns Project project directory path
|
|
244
244
|
*/
|
|
245
245
|
getWorkingDirectory() {
|
|
246
|
-
return this.resolvedConfig.values.
|
|
246
|
+
return this.resolvedConfig.values.projectDirectory ?? process.cwd();
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
249
249
|
* Join path segments.
|
|
@@ -45,7 +45,7 @@ function createCartridgeDeployTool(loadServices, injections) {
|
|
|
45
45
|
directory: z
|
|
46
46
|
.string()
|
|
47
47
|
.optional()
|
|
48
|
-
.describe('Path to directory to search for cartridges. Defaults to current
|
|
48
|
+
.describe('Path to directory to search for cartridges. Defaults to current project directory if not specified. ' +
|
|
49
49
|
'The tool will recursively search this directory for .project files to identify cartridges.'),
|
|
50
50
|
cartridges: z
|
|
51
51
|
.array(z.string())
|
|
@@ -83,7 +83,7 @@ function createCartridgeDeployTool(loadServices, injections) {
|
|
|
83
83
|
codeVersion = active.id;
|
|
84
84
|
instance.config.codeVersion = codeVersion;
|
|
85
85
|
}
|
|
86
|
-
// Resolve directory path: relative paths are resolved relative to
|
|
86
|
+
// Resolve directory path: relative paths are resolved relative to project directory, absolute paths are used as-is
|
|
87
87
|
const directory = args.directory
|
|
88
88
|
? path.isAbsolute(args.directory)
|
|
89
89
|
? args.directory
|
|
@@ -530,7 +530,7 @@ export function createPageDesignerDecoratorTool(loadServices) {
|
|
|
530
530
|
name: 'storefront_next_page_designer_decorator',
|
|
531
531
|
description: 'Adds Page Designer decorators (@Component, @AttributeDefinition, @RegionDefinition) to React components. ' +
|
|
532
532
|
'Two modes: autoMode=true for quick setup with defaults, or interactive mode via conversationContext.step. ' +
|
|
533
|
-
'Component discovery uses
|
|
533
|
+
'Component discovery uses projectDirectory from flags/env. ' +
|
|
534
534
|
'Auto mode: selects suitable props, infers types, generates code immediately. ' +
|
|
535
535
|
'Interactive mode: multi-step workflow (analyze → select_props → configure_attrs → configure_regions → confirm_generation).',
|
|
536
536
|
inputSchema: pageDesignerDecoratorSchema.shape,
|
|
@@ -540,7 +540,7 @@ export function createPageDesignerDecoratorTool(loadServices) {
|
|
|
540
540
|
try {
|
|
541
541
|
// Validate and parse input
|
|
542
542
|
const validatedArgs = pageDesignerDecoratorSchema.parse(args);
|
|
543
|
-
// Use
|
|
543
|
+
// Use projectDirectory from services to ensure we search in the correct project directory
|
|
544
544
|
// This prevents searches in the home folder when MCP clients spawn servers from ~
|
|
545
545
|
const services = loadServices();
|
|
546
546
|
const workspaceRoot = services.getWorkingDirectory();
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -40,6 +40,6 @@ export interface StartupFlags {
|
|
|
40
40
|
allowNonGaTools?: boolean;
|
|
41
41
|
/** Path to config file (dw.json format) */
|
|
42
42
|
configPath?: string;
|
|
43
|
-
/** Project
|
|
44
|
-
|
|
43
|
+
/** Project project directory for tools (auto-discovery, scaffolding, etc.) */
|
|
44
|
+
projectDirectory?: string;
|
|
45
45
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"Symbol(SINGLE_COMMAND_CLI)": {
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {},
|
|
6
|
-
"description": "Salesforce B2C Commerce
|
|
6
|
+
"description": "Salesforce B2C Commerce Developer Experience MCP Server - Expose B2C Commerce Developer Experience tools to AI assistants",
|
|
7
7
|
"examples": [
|
|
8
8
|
{
|
|
9
9
|
"description": "All toolsets",
|
|
@@ -387,5 +387,5 @@
|
|
|
387
387
|
"enableJsonFlag": false
|
|
388
388
|
}
|
|
389
389
|
},
|
|
390
|
-
"version": "0.4.
|
|
390
|
+
"version": "0.4.4"
|
|
391
391
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/b2c-dx-mcp",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"description": "MCP server for B2C Commerce developer experience tools",
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "SalesforceCommerceCloud/b2c-developer-tooling",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"ts-morph": "^27.0.0",
|
|
80
80
|
"yaml": "2.8.1",
|
|
81
81
|
"zod": "3.25.76",
|
|
82
|
-
"@salesforce/b2c-tooling-sdk": "0.5.
|
|
82
|
+
"@salesforce/b2c-tooling-sdk": "0.5.4"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@eslint/compat": "^1",
|