@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
package/README.md
CHANGED
|
@@ -1,45 +1,438 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Salesforce Commerce Cloud B2C MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP (Model Context Protocol) server for Salesforce B2C Commerce Cloud developer experience tools.
|
|
4
4
|
|
|
5
|
-
**This package is
|
|
5
|
+
> ⚠️ **Active Development**: This package is under active development. All tools are currently **placeholder implementations** that return mock responses. Tool implementations will be added incrementally.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Overview
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This MCP server enables AI assistants to help with B2C Commerce development tasks. It provides toolsets for **SCAPI**, **CARTRIDGES**, **MRT**, **PWAV3**, and **STOREFRONTNEXT** development.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@salesforce/b2c-dx-mcp`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
11
|
+
The server automatically detects your project type and enables relevant tools. See [Available Toolsets and Tools](#available-toolsets-and-tools) for details.
|
|
15
12
|
|
|
16
|
-
##
|
|
13
|
+
## Usage
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
### Working Directory and Auto-Discovery
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
The most important flag is **`--working-directory`** (or env var `SFCC_WORKING_DIRECTORY`). It tells the server where your project is located, enabling:
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
1. **Auto-discovery** - Detects your project type and enables appropriate toolsets
|
|
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
|
+
3. **Scaffolding** - Creates new files in the correct location
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
23
|
+
> **Important:** MCP clients like Cursor and Claude Desktop spawn servers from the home directory (`~`), not your project. Always set `--working-directory`.
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
<!-- TODO: Update command to use npx once published to npm -->
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
27
|
+
**Cursor** (supports `${workspaceFolder}`):
|
|
36
28
|
|
|
37
|
-
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcpServers": {
|
|
32
|
+
"b2c-dx": {
|
|
33
|
+
"command": "node",
|
|
34
|
+
"args": ["/path/to/packages/b2c-dx-mcp/bin/dev.js", "--working-directory", "${workspaceFolder}", "--allow-non-ga-tools"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
40
|
+
**Claude Desktop** (use explicit path):
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"b2c-dx": {
|
|
46
|
+
"command": "node",
|
|
47
|
+
"args": ["/path/to/packages/b2c-dx-mcp/bin/dev.js", "--working-directory", "/path/to/your/project", "--allow-non-ga-tools"]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
44
52
|
|
|
45
|
-
|
|
53
|
+
### Project Type Detection
|
|
54
|
+
|
|
55
|
+
The server analyzes your working directory and enables toolsets based on what it finds:
|
|
56
|
+
|
|
57
|
+
| Project Type | Detection | Toolsets Enabled |
|
|
58
|
+
|--------------|-----------|------------------|
|
|
59
|
+
| **PWA Kit v3** | `@salesforce/pwa-kit-*`, `@salesforce/retail-react-app`, or `ccExtensibility` in package.json | PWAV3, MRT, SCAPI |
|
|
60
|
+
| **Storefront Next** | `@salesforce/storefront-next-*` in package.json | STOREFRONTNEXT, MRT, SCAPI |
|
|
61
|
+
| **Cartridges** | `.project` file in cartridge directory | CARTRIDGES, SCAPI |
|
|
62
|
+
| **No project detected** | No B2C markers found | SCAPI (base toolset only) |
|
|
63
|
+
|
|
64
|
+
The **SCAPI** toolset is always enabled. Hybrid projects (e.g., cartridges + PWA Kit) get combined toolsets.
|
|
65
|
+
|
|
66
|
+
### Manual Toolset Selection
|
|
67
|
+
|
|
68
|
+
Override auto-discovery by specifying toolsets explicitly:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
"args": ["--working-directory", "${workspaceFolder}", "--toolsets", "CARTRIDGES,MRT", "--allow-non-ga-tools"]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Prompting Tips and Examples
|
|
75
|
+
|
|
76
|
+
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.
|
|
77
|
+
|
|
78
|
+
> ⚠️ **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.
|
|
79
|
+
|
|
80
|
+
#### Best Practices
|
|
81
|
+
|
|
82
|
+
1. **Always explicitly request MCP tool usage** (see warning above): Start prompts with "Use the MCP tool to..." or include "Use the MCP tool" in your request.
|
|
83
|
+
2. **Be specific about your goal**: Instead of "help me with Storefront Next", say "Use the MCP tool to show me how to build a product detail page with authentication"
|
|
84
|
+
3. **Mention the tool or domain explicitly**: Reference the framework (Storefront Next, PWA Kit), operation (deploy, discover), or domain (SCAPI, cartridges)
|
|
85
|
+
4. **Use natural language**: Describe what you want to achieve, not the tool name
|
|
86
|
+
5. **Provide context**: Mention your project type, what you're building, or what you need to learn
|
|
87
|
+
6. **Ask for guidelines first**: When starting a new project or learning a framework, ask for development guidelines before writing code
|
|
88
|
+
|
|
89
|
+
#### Examples by Tool Category
|
|
90
|
+
|
|
91
|
+
##### Storefront Next Development Guidelines
|
|
92
|
+
|
|
93
|
+
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.
|
|
94
|
+
|
|
95
|
+
**Good prompts:**
|
|
96
|
+
- ✅ "I'm new to Storefront Next. Use the MCP tool to show me the critical rules I need to know."
|
|
97
|
+
- ✅ "I need to build a product detail page. Use the MCP tool to show me best practices for data fetching and component patterns."
|
|
98
|
+
- ✅ "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."
|
|
99
|
+
- ✅ "Use the MCP tool to show me the data fetching patterns for Storefront Next."
|
|
100
|
+
- ✅ "Show me all available Storefront Next development guidelines."
|
|
101
|
+
|
|
102
|
+
**Available sections:**
|
|
103
|
+
- `quick-reference` - Critical rules and architecture principles (default)
|
|
104
|
+
- `data-fetching` - Data loading patterns with loaders
|
|
105
|
+
- `state-management` - Client-side state management
|
|
106
|
+
- `auth` - Authentication and session management
|
|
107
|
+
- `components` - Component patterns and best practices
|
|
108
|
+
- `styling` - Tailwind CSS 4, Shadcn/ui, styling guidelines
|
|
109
|
+
- `page-designer` - Page Designer integration
|
|
110
|
+
- `performance` - Performance optimization
|
|
111
|
+
- `testing` - Testing strategies
|
|
112
|
+
- `i18n` - Internationalization patterns
|
|
113
|
+
- `config` - Configuration management
|
|
114
|
+
- `extensions` - Extension development
|
|
115
|
+
- `pitfalls` - Common pitfalls
|
|
116
|
+
|
|
117
|
+
##### PWA Kit Development
|
|
118
|
+
|
|
119
|
+
**Good prompts:**
|
|
120
|
+
- ✅ "I'm starting a new PWA Kit project. Use the MCP tool to get the development guidelines."
|
|
121
|
+
- ✅ "Use the MCP tool to create a new product listing page component in my PWA Kit project."
|
|
122
|
+
- ✅ "Use the MCP tool to recommend React hooks for fetching product data in PWA Kit."
|
|
123
|
+
- ✅ "Use the MCP tool to explore the SCAPI Shop API endpoints available for my PWA Kit storefront."
|
|
124
|
+
|
|
125
|
+
##### SCAPI Discovery
|
|
126
|
+
|
|
127
|
+
**Good prompts:**
|
|
128
|
+
- ✅ "Use the MCP tool to discover what SCAPI endpoints are available for product data."
|
|
129
|
+
- ✅ "Use the MCP tool to discover custom SCAPI APIs in my B2C instance."
|
|
130
|
+
- ✅ "Use the MCP tool to show me all available SCAPI endpoints and their capabilities."
|
|
131
|
+
- ✅ "Use the MCP tool to scaffold a new custom SCAPI API for order management."
|
|
132
|
+
|
|
133
|
+
##### Cartridge Deployment
|
|
134
|
+
|
|
135
|
+
**Good prompts:**
|
|
136
|
+
- ✅ "Use the MCP tool to deploy my cartridges to the sandbox instance."
|
|
137
|
+
- ✅ "Use the MCP tool to deploy only the app_storefront_base cartridge to production."
|
|
138
|
+
- ✅ "Use the MCP tool to deploy cartridges from the ./cartridges directory and reload the code version."
|
|
139
|
+
|
|
140
|
+
##### MRT Bundle Operations
|
|
141
|
+
|
|
142
|
+
**Good prompts:**
|
|
143
|
+
- ✅ "Use the MCP tool to build and push my Storefront Next bundle to staging."
|
|
144
|
+
- ✅ "Use the MCP tool to push the bundle from ./build directory to Managed Runtime."
|
|
145
|
+
- ✅ "Use the MCP tool to deploy my PWA Kit bundle to production with a deployment message."
|
|
146
|
+
|
|
147
|
+
#### Tips for Better Results
|
|
148
|
+
|
|
149
|
+
- **Start with guidelines**: When learning a new framework, ask for development guidelines first using "Use the MCP tool to get..."
|
|
150
|
+
- **Combine related topics**: Ask for multiple related sections (e.g., "data fetching and components") in one request
|
|
151
|
+
- **Provide project context**: Mention your project type (Storefront Next, PWA Kit, cartridges) for better tool selection
|
|
152
|
+
- **Specify operations clearly**: For deployment operations, mention the target (sandbox, staging, production) and what to deploy
|
|
153
|
+
|
|
154
|
+
### Configuration
|
|
155
|
+
|
|
156
|
+
Credentials can be provided via **config files** (recommended), **environment variables**, or **flags**. Priority: Flags > Env vars > Config files.
|
|
157
|
+
|
|
158
|
+
| Toolset | Required Credentials |
|
|
159
|
+
|---------|---------------------|
|
|
160
|
+
| **SCAPI** | `hostname` + `client-id` + `client-secret` |
|
|
161
|
+
| **CARTRIDGES** | `hostname` + `username` + `password` (or OAuth) |
|
|
162
|
+
| **MRT** | `api-key` + `project` (optionally `environment`) |
|
|
163
|
+
| **PWAV3** | `--working-directory` only (+ MRT config for deployments) |
|
|
164
|
+
| **STOREFRONTNEXT** | `--working-directory` only (+ MRT/CARTRIDGES config for those tools) |
|
|
165
|
+
|
|
166
|
+
**Option 1: Config files (recommended)**
|
|
167
|
+
|
|
168
|
+
B2C credentials — [`dw.json`](https://salesforcecommercecloud.github.io/b2c-developer-tooling/guide/configuration.html#configuration-file) in your project root:
|
|
169
|
+
```json
|
|
170
|
+
{ "hostname": "xxx.demandware.net", "username": "...", "password": "...", "client-id": "...", "client-secret": "..." }
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
MRT credentials — [`~/.mobify`](https://salesforcecommercecloud.github.io/b2c-developer-tooling/guide/configuration.html#mobify-config-file) (create manually or via [B2C CLI](https://salesforcecommercecloud.github.io/b2c-developer-tooling/cli/mrt.html)):
|
|
174
|
+
```json
|
|
175
|
+
{ "api_key": "..." }
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Option 2: Environment variables**
|
|
179
|
+
```json
|
|
180
|
+
"env": { "SFCC_SERVER": "xxx.demandware.net", "SFCC_USERNAME": "...", "SFCC_PASSWORD": "...", "SFCC_MRT_API_KEY": "..." }
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Option 3: Flags**
|
|
184
|
+
```json
|
|
185
|
+
"args": ["--server", "xxx.demandware.net", "--username", "...", "--password", "...", "--api-key", "..."]
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
See [Flag Reference](#flag-reference) for all available flags and env vars.
|
|
189
|
+
|
|
190
|
+
- `username`/`password` = B2C username + [WebDAV access key](https://help.salesforce.com/s/articleView?id=cc.b2c_account_manager_sso_use_webdav_file_access.htm&type=5)
|
|
191
|
+
- `client-id`/`client-secret` = API client credentials from Account Manager
|
|
192
|
+
|
|
193
|
+
### Flag Reference
|
|
194
|
+
|
|
195
|
+
<details>
|
|
196
|
+
<summary>Click to expand flag reference</summary>
|
|
197
|
+
|
|
198
|
+
#### Core Flags
|
|
199
|
+
|
|
200
|
+
| Flag | Env Variable | Description |
|
|
201
|
+
|------|--------------|-------------|
|
|
202
|
+
| `--working-directory` | `SFCC_WORKING_DIRECTORY` | Project directory (enables auto-discovery and config loading) |
|
|
203
|
+
| `--toolsets` | — | Comma-separated toolsets to enable |
|
|
204
|
+
| `--tools` | — | Comma-separated individual tools to enable |
|
|
205
|
+
| `--allow-non-ga-tools` | — | Enable experimental (non-GA) tools |
|
|
206
|
+
| `--config` | — | Explicit path to [`dw.json`](https://salesforcecommercecloud.github.io/b2c-developer-tooling/guide/configuration.html#configuration-file) (advanced) |
|
|
207
|
+
| `--log-level` | — | Logging verbosity (trace, debug, info, warn, error, silent) |
|
|
208
|
+
| `--debug` | — | Enable debug logging |
|
|
209
|
+
|
|
210
|
+
#### B2C Instance Flags
|
|
211
|
+
|
|
212
|
+
| Flag | Env Variable | Description |
|
|
213
|
+
|------|--------------|-------------|
|
|
214
|
+
| `--server` | `SFCC_SERVER` | B2C instance hostname |
|
|
215
|
+
| `--username` | `SFCC_USERNAME` | Username for Basic auth (WebDAV) |
|
|
216
|
+
| `--password` | `SFCC_PASSWORD` | Password/access key for Basic auth |
|
|
217
|
+
| `--client-id` | `SFCC_CLIENT_ID` | OAuth client ID |
|
|
218
|
+
| `--client-secret` | `SFCC_CLIENT_SECRET` | OAuth client secret |
|
|
219
|
+
| `--code-version` | `SFCC_CODE_VERSION` | Code version for deployments |
|
|
220
|
+
|
|
221
|
+
#### MRT Flags
|
|
222
|
+
|
|
223
|
+
| Flag | Env Variable | Description |
|
|
224
|
+
|------|--------------|-------------|
|
|
225
|
+
| `--api-key` | `SFCC_MRT_API_KEY` | MRT API key |
|
|
226
|
+
| `--project` | `SFCC_MRT_PROJECT` | MRT project slug |
|
|
227
|
+
| `--environment` | `SFCC_MRT_ENVIRONMENT` | MRT environment (staging, production) |
|
|
228
|
+
| `--cloud-origin` | `SFCC_MRT_CLOUD_ORIGIN` | MRT cloud origin URL |
|
|
229
|
+
|
|
230
|
+
</details>
|
|
231
|
+
|
|
232
|
+
### Available Toolsets and Tools
|
|
233
|
+
|
|
234
|
+
Use `--toolsets all` to enable all toolsets, or select specific ones with `--toolsets CARTRIDGES,MRT`.
|
|
235
|
+
|
|
236
|
+
> **Note:** All tools are currently placeholder implementations. Use `--allow-non-ga-tools` flag to enable them.
|
|
237
|
+
|
|
238
|
+
#### CARTRIDGES
|
|
239
|
+
Cartridge development, deployment, and code version management.
|
|
240
|
+
- **Status:** 🚧 Early Access
|
|
241
|
+
|
|
242
|
+
| Tool | Description |
|
|
243
|
+
|------|-------------|
|
|
244
|
+
| `cartridge_deploy` | Deploy cartridges to a B2C Commerce instance |
|
|
245
|
+
|
|
246
|
+
#### MRT
|
|
247
|
+
Managed Runtime operations for PWA Kit and Storefront Next deployments.
|
|
248
|
+
- **Status:** 🚧 Early Access
|
|
249
|
+
|
|
250
|
+
| Tool | Description |
|
|
251
|
+
|------|-------------|
|
|
252
|
+
| `mrt_bundle_push` | Build, push bundle (optionally deploy) |
|
|
253
|
+
|
|
254
|
+
#### PWAV3
|
|
255
|
+
PWA Kit v3 development tools for building headless storefronts.
|
|
256
|
+
- **Status:** 🚧 Placeholder
|
|
257
|
+
|
|
258
|
+
| Tool | Description |
|
|
259
|
+
|------|-------------|
|
|
260
|
+
| `pwakit_create_storefront` | Create a new PWA Kit storefront project |
|
|
261
|
+
| `pwakit_create_page` | Create a new page component in PWA Kit project |
|
|
262
|
+
| `pwakit_create_component` | Create a new React component in PWA Kit project |
|
|
263
|
+
| `pwakit_get_dev_guidelines` | Get PWA Kit development guidelines and best practices |
|
|
264
|
+
| `pwakit_recommend_hooks` | Recommend appropriate React hooks for PWA Kit use cases |
|
|
265
|
+
| `pwakit_run_site_test` | Run site tests for PWA Kit project |
|
|
266
|
+
| `pwakit_install_agent_rules` | Install AI agent rules for PWA Kit development |
|
|
267
|
+
| `pwakit_explore_scapi_shop_api` | Explore SCAPI Shop API endpoints and capabilities |
|
|
268
|
+
| `scapi_discovery` | Discover available SCAPI endpoints and capabilities |
|
|
269
|
+
| `scapi_custom_api_discovery` | Discover custom SCAPI API endpoints |
|
|
270
|
+
| `mrt_bundle_push` | Build, push bundle (optionally deploy) |
|
|
271
|
+
|
|
272
|
+
#### SCAPI
|
|
273
|
+
Salesforce Commerce API discovery and exploration.
|
|
274
|
+
- **Status:** 🚧 Placeholder
|
|
275
|
+
|
|
276
|
+
| Tool | Description |
|
|
277
|
+
|------|-------------|
|
|
278
|
+
| `scapi_discovery` | Discover available SCAPI endpoints and capabilities |
|
|
279
|
+
| `scapi_customapi_scaffold` | Scaffold a new custom SCAPI API |
|
|
280
|
+
| `scapi_custom_api_discovery` | Discover custom SCAPI API endpoints |
|
|
281
|
+
|
|
282
|
+
#### STOREFRONTNEXT
|
|
283
|
+
Storefront Next development tools for building modern storefronts.
|
|
284
|
+
- **Status:** 🚧 Placeholder
|
|
285
|
+
|
|
286
|
+
| Tool | Description |
|
|
287
|
+
|------|-------------|
|
|
288
|
+
| `storefront_next_development_guidelines` | Get Storefront Next development guidelines and best practices |
|
|
289
|
+
| `storefront_next_site_theming` | Configure and manage site theming for Storefront Next |
|
|
290
|
+
| `storefront_next_figma_to_component_workflow` | Convert Figma designs to Storefront Next components |
|
|
291
|
+
| `storefront_next_generate_component` | Generate a new Storefront Next component |
|
|
292
|
+
| `storefront_next_map_tokens_to_theme` | Map design tokens to Storefront Next theme configuration |
|
|
293
|
+
| `storefront_next_design_decorator` | Apply design decorators to Storefront Next components |
|
|
294
|
+
| `storefront_next_generate_page_designer_metadata` | Generate Page Designer metadata for Storefront Next components |
|
|
295
|
+
| `scapi_discovery` | Discover available SCAPI endpoints and capabilities |
|
|
296
|
+
| `scapi_custom_api_discovery` | Discover custom SCAPI API endpoints |
|
|
297
|
+
| `mrt_bundle_push` | Build, push bundle (optionally deploy) |
|
|
298
|
+
|
|
299
|
+
> **Note:** Some tools appear in multiple toolsets (e.g., `mrt_bundle_push`, `scapi_discovery`). When using multiple toolsets, tools are automatically deduplicated.
|
|
300
|
+
|
|
301
|
+
## Telemetry
|
|
302
|
+
|
|
303
|
+
The MCP server collects anonymous usage telemetry to help improve the developer experience. Telemetry is enabled by default.
|
|
304
|
+
|
|
305
|
+
**Development mode**: Telemetry is automatically disabled when using `bin/dev.js`, so local development and testing won't pollute production data.
|
|
306
|
+
|
|
307
|
+
### Configuring telemetry
|
|
308
|
+
|
|
309
|
+
Set options in the `env` object of your server entry in `.cursor/mcp.json` or `~/.cursor/mcp.json` (the client injects these when it starts the server):
|
|
310
|
+
|
|
311
|
+
- **Disable**: `SF_DISABLE_TELEMETRY=true` or `SFCC_DISABLE_TELEMETRY=true`
|
|
312
|
+
- **Custom endpoint**: `SFCC_APP_INSIGHTS_KEY=your-key`
|
|
313
|
+
|
|
314
|
+
### What We Collect
|
|
315
|
+
|
|
316
|
+
- **Server lifecycle events**: When the server starts, stops, or encounters errors
|
|
317
|
+
- **Tool usage**: Which tools are called and their execution time (not the arguments or results)
|
|
318
|
+
- **Command metrics**: Command duration and success/failure status
|
|
319
|
+
- **Environment info**: Platform, architecture, Node.js version, and package version
|
|
320
|
+
|
|
321
|
+
### What We Don't Collect
|
|
322
|
+
|
|
323
|
+
- **No credentials**: No API keys, passwords, or secrets
|
|
324
|
+
- **No business data**: No product data, customer information, or site content
|
|
325
|
+
- **No tool arguments**: No input parameters or output results from tool calls
|
|
326
|
+
- **No file contents**: No source code, configuration files, or project data
|
|
327
|
+
|
|
328
|
+
## Development
|
|
329
|
+
|
|
330
|
+
### Quick Start
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
# Install dependencies (from monorepo root)
|
|
334
|
+
pnpm install
|
|
335
|
+
|
|
336
|
+
# Navigate to the package directory
|
|
337
|
+
cd packages/b2c-dx-mcp
|
|
338
|
+
|
|
339
|
+
# Launch MCP Inspector for development (no build needed, uses TypeScript directly)
|
|
340
|
+
pnpm run inspect:dev
|
|
341
|
+
|
|
342
|
+
# Launch MCP Inspector with production build (runs build first)
|
|
343
|
+
pnpm run inspect
|
|
344
|
+
|
|
345
|
+
# Build the package
|
|
346
|
+
pnpm run build
|
|
347
|
+
|
|
348
|
+
# Run tests (includes linting)
|
|
349
|
+
pnpm run test
|
|
350
|
+
|
|
351
|
+
# Format code
|
|
352
|
+
pnpm run format
|
|
353
|
+
|
|
354
|
+
# Run linter only
|
|
355
|
+
pnpm run lint
|
|
356
|
+
|
|
357
|
+
# Clean build artifacts
|
|
358
|
+
pnpm run clean
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Working Directory
|
|
362
|
+
|
|
363
|
+
Commands should be run from the `packages/b2c-dx-mcp` directory:
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
cd packages/b2c-dx-mcp
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Or use pnpm's filter flag from the monorepo root:
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
pnpm --filter @salesforce/b2c-dx-mcp run <script>
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Testing the MCP Server Locally
|
|
376
|
+
|
|
377
|
+
#### 1. MCP Inspector
|
|
378
|
+
|
|
379
|
+
Use MCP Inspector to browse tools and test them in a web UI:
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
pnpm run inspect:dev
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
This runs TypeScript directly (no build needed). Open the localhost URL shown in the terminal, click **Connect**, then **List Tools** to see available tools.
|
|
386
|
+
|
|
387
|
+
For CLI-based testing:
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
# List all tools
|
|
391
|
+
npx mcp-inspector --cli node bin/dev.js --toolsets all --allow-non-ga-tools --method tools/list
|
|
392
|
+
|
|
393
|
+
# Call a specific tool
|
|
394
|
+
npx mcp-inspector --cli node bin/dev.js --toolsets all --allow-non-ga-tools \
|
|
395
|
+
--method tools/call \
|
|
396
|
+
--tool-name storefront_next_design_decorator
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
#### 2. IDE Integration
|
|
400
|
+
|
|
401
|
+
Configure your IDE to use the local MCP server. Add this to your IDE's MCP configuration:
|
|
402
|
+
|
|
403
|
+
```json
|
|
404
|
+
{
|
|
405
|
+
"mcpServers": {
|
|
406
|
+
"b2c-dx-local": {
|
|
407
|
+
"command": "node",
|
|
408
|
+
"args": [
|
|
409
|
+
"/full/path/to/packages/b2c-dx-mcp/bin/dev.js",
|
|
410
|
+
"--toolsets", "all",
|
|
411
|
+
"--allow-non-ga-tools"
|
|
412
|
+
]
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
> **Note:** Make sure the script is executable: `chmod +x /full/path/to/packages/b2c-dx-mcp/bin/dev.js`
|
|
419
|
+
>
|
|
420
|
+
> The script's shebang (`#!/usr/bin/env -S node --conditions development`) handles Node.js setup automatically.
|
|
421
|
+
|
|
422
|
+
> **Note:** Restart the MCP server in your IDE to pick up code changes.
|
|
423
|
+
|
|
424
|
+
#### 3. JSON-RPC via stdin
|
|
425
|
+
|
|
426
|
+
Send raw MCP protocol messages:
|
|
427
|
+
|
|
428
|
+
```bash
|
|
429
|
+
# List all tools (--allow-non-ga-tools required for placeholder tools)
|
|
430
|
+
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node bin/dev.js --toolsets all --allow-non-ga-tools
|
|
431
|
+
|
|
432
|
+
# Call a specific tool
|
|
433
|
+
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"cartridge_deploy","arguments":{}}}' | node bin/dev.js --toolsets all --allow-non-ga-tools
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## License
|
|
437
|
+
|
|
438
|
+
Apache-2.0
|
package/bin/run.cmd
ADDED
package/bin/run.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2
|
|
5
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*/
|
|
7
|
+
/* global process */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Production entry point for MCP server using oclif.
|
|
11
|
+
*
|
|
12
|
+
* This uses oclif's production mode which:
|
|
13
|
+
* - Uses compiled JavaScript from dist/
|
|
14
|
+
* - Loads .env file if present for local configuration
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Load .env file if present (Node.js native support)
|
|
19
|
+
try {
|
|
20
|
+
process.loadEnvFile();
|
|
21
|
+
} catch {
|
|
22
|
+
// .env file not found or not readable, continue without it
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
import {execute} from '@oclif/core';
|
|
26
|
+
|
|
27
|
+
await execute({dir: import.meta.url});
|
package/content/auth.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Authentication & Session Management
|
|
2
|
+
|
|
3
|
+
## Architecture
|
|
4
|
+
|
|
5
|
+
Split-cookie architecture with server/client contexts:
|
|
6
|
+
|
|
7
|
+
- **Server middleware** (`auth.server.ts`): Manages SLAS tokens, writes cookies
|
|
8
|
+
- **Client middleware** (`auth.client.ts`): Reads cookies, maintains cache
|
|
9
|
+
- **React Context** (`AuthProvider`): Provides auth state to components
|
|
10
|
+
|
|
11
|
+
## Cookie Design
|
|
12
|
+
|
|
13
|
+
| Cookie Name | Purpose | User Type | Expiry | HttpOnly |
|
|
14
|
+
|-------------|---------|-----------|--------|----------|
|
|
15
|
+
| `cc-nx-g` | Guest refresh token | Guest | 30 days | No |
|
|
16
|
+
| `cc-nx` | Registered refresh token | Registered | 90 days | No |
|
|
17
|
+
| `cc-at` | Access token | Both | 30 min | No |
|
|
18
|
+
| `usid` | User session ID | Both | Matches refresh | No |
|
|
19
|
+
| `customerId` | Customer ID | Registered | Matches refresh | No |
|
|
20
|
+
|
|
21
|
+
**Key Points**:
|
|
22
|
+
|
|
23
|
+
- Only ONE refresh token exists (guest OR registered, never both)
|
|
24
|
+
- User type derived from which refresh token exists
|
|
25
|
+
- Cookies auto-namespaced with `siteId`
|
|
26
|
+
- Tokens auto-refresh when expired
|
|
27
|
+
|
|
28
|
+
## Usage in Loaders/Actions
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { getAuth } from '@/middlewares/auth.server';
|
|
32
|
+
|
|
33
|
+
export function loader({ context }: LoaderFunctionArgs) {
|
|
34
|
+
const auth = getAuth(context);
|
|
35
|
+
|
|
36
|
+
// Access auth properties
|
|
37
|
+
const accessToken = auth.access_token;
|
|
38
|
+
const customerId = auth.customer_id;
|
|
39
|
+
const isGuest = auth.userType === 'guest';
|
|
40
|
+
const isRegistered = auth.userType === 'registered';
|
|
41
|
+
|
|
42
|
+
return { isGuest, customerId };
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage in Components
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { useAuth } from '@/providers/auth';
|
|
50
|
+
|
|
51
|
+
export function MyComponent() {
|
|
52
|
+
const auth = useAuth();
|
|
53
|
+
|
|
54
|
+
if (auth?.userType === 'guest') {
|
|
55
|
+
return <LoginPrompt />;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return <div>Welcome, customer {auth?.customer_id}</div>;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Reference:** See README-AUTH.md for complete authentication documentation.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Component Patterns
|
|
2
|
+
|
|
3
|
+
## Use the `createPage` HOC
|
|
4
|
+
|
|
5
|
+
The `createPage` higher-order component standardizes page patterns with built-in Suspense and page key handling:
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { use } from 'react';
|
|
9
|
+
import { createPage } from '@/components/create-page';
|
|
10
|
+
|
|
11
|
+
// Define your view component
|
|
12
|
+
function ProductView({
|
|
13
|
+
product,
|
|
14
|
+
category
|
|
15
|
+
}: {
|
|
16
|
+
product: Promise<Product>;
|
|
17
|
+
category?: Promise<Category>
|
|
18
|
+
}) {
|
|
19
|
+
const productData = use(product);
|
|
20
|
+
const categoryData = category ? use(category) : null;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<h1>{productData.name}</h1>
|
|
25
|
+
{categoryData && <p>Category: {categoryData.name}</p>}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Create page with fallback
|
|
31
|
+
const ProductPage = createPage({
|
|
32
|
+
component: ProductView,
|
|
33
|
+
fallback: <ProductSkeleton />
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export default ProductPage;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Benefits:**
|
|
40
|
+
|
|
41
|
+
- Eliminates repetitive Suspense/Await boilerplate
|
|
42
|
+
- Consistent loading states across pages
|
|
43
|
+
- Built-in page key management for navigation transitions
|
|
44
|
+
- Type-safe with full TypeScript support
|
|
45
|
+
|
|
46
|
+
## shadcn/ui Components
|
|
47
|
+
|
|
48
|
+
**RULES**:
|
|
49
|
+
|
|
50
|
+
- ✅ Add via: `npx shadcn@latest add <component-name>`
|
|
51
|
+
- ❌ DO NOT modify `src/components/ui/` directly
|
|
52
|
+
- ✅ Create custom components elsewhere
|
|
53
|
+
|
|
54
|
+
## Suspense Boundaries
|
|
55
|
+
|
|
56
|
+
Use granular Suspense boundaries for better UX:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
// ✅ RECOMMENDED - Multiple Suspense boundaries
|
|
60
|
+
export default function ProductPage({ loaderData: { product, reviews } }) {
|
|
61
|
+
return (
|
|
62
|
+
<div>
|
|
63
|
+
<Suspense fallback={<ProductHeaderSkeleton />}>
|
|
64
|
+
<Await resolve={product}>
|
|
65
|
+
{(data) => <ProductHeader product={data} />}
|
|
66
|
+
</Await>
|
|
67
|
+
</Suspense>
|
|
68
|
+
|
|
69
|
+
<Suspense fallback={<ReviewsSkeleton />}>
|
|
70
|
+
<Await resolve={reviews}>
|
|
71
|
+
{(data) => <ProductReviews reviews={data} />}
|
|
72
|
+
</Await>
|
|
73
|
+
</Suspense>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ⚠️ OK - Single Suspense boundary (less granular)
|
|
79
|
+
export default createPage({
|
|
80
|
+
component: ProductView,
|
|
81
|
+
fallback: <ProductPageSkeleton />
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## File Organization
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
src/components/product-tile/
|
|
89
|
+
├── index.tsx # Component
|
|
90
|
+
├── index.test.tsx # Tests
|
|
91
|
+
└── stories/
|
|
92
|
+
├── index.stories.tsx # Storybook stories
|
|
93
|
+
└── __snapshots__/ # Storybook snapshots (optional)
|
|
94
|
+
└── product-tile-snapshot.tsx.snap
|
|
95
|
+
|
|
96
|
+
# Skeleton components are separate components
|
|
97
|
+
src/components/product-skeleton/
|
|
98
|
+
├── index.tsx
|
|
99
|
+
├── index.test.tsx
|
|
100
|
+
└── stories/
|
|
101
|
+
└── index.stories.tsx
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Styling
|
|
105
|
+
|
|
106
|
+
**Tailwind CSS 4** is the only styling approach allowed. Use utility classes directly in components.
|
|
107
|
+
|
|
108
|
+
**Key rules:**
|
|
109
|
+
|
|
110
|
+
- ✅ Use Tailwind utility classes
|
|
111
|
+
- ✅ Use `cn()` utility for conditional classes
|
|
112
|
+
- ❌ NO inline styles, NO CSS modules, NO separate CSS files
|
|
113
|
+
|
|
114
|
+
**See `styling` section for:** Tailwind CSS 4, Shadcn/ui components, icons, responsive design, theme configuration, dark mode, best practices
|
|
115
|
+
|
|
116
|
+
## Best Practices
|
|
117
|
+
|
|
118
|
+
1. **Extract view components** - Separate data handling from presentation
|
|
119
|
+
2. **Type safety** - Define proper TypeScript interfaces
|
|
120
|
+
3. **Consistent fallbacks** - Reusable skeleton components
|
|
121
|
+
4. **Colocate tests** - Keep tests next to components
|
|
122
|
+
5. **Story coverage** - Create stories for all reusable components
|
|
123
|
+
6. **Tailwind utilities only** - Use Tailwind CSS classes, avoid inline styles or CSS modules
|