Skip to content

Commit a98d28d

Browse files
authored
@W-20599722 improve mcp docs (#287)
1 parent 49471cd commit a98d28d

8 files changed

Lines changed: 261 additions & 268 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@salesforce/b2c-dx-docs': patch
3+
---
4+
5+
Clarified MCP documentation for quick install and configuration, including project-root setup steps, environment variable guidance, and MRT/theming tool setup details to reduce onboarding confusion.

docs/guide/index.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,44 @@ See the [CLI Installation Guide](./installation) for more installation options.
3333

3434
The B2C DX MCP Server enables AI assistants to help with B2C Commerce development tasks.
3535

36-
**Claude Code:**
36+
### Claude Code (Project Scope)
3737

38-
::: code-group
38+
1. Open your project root in Claude Code.
39+
2. Install the plugin marketplace entry:
3940

40-
```bash [Project Scope (Recommended)]
41-
cd /path/to/your/project
42-
claude mcp add --transport stdio --scope project b2c-dx-mcp -- npx -y @salesforce/b2c-dx-mcp@latest --allow-non-ga-tools
41+
```bash
42+
claude plugin marketplace add SalesforceCommerceCloud/b2c-developer-tooling
43+
claude plugin install b2c-dx-mcp --scope project
4344
```
4445

45-
```bash [User Scope]
46-
claude mcp add --transport stdio --scope user b2c-dx-mcp -- npx -y @salesforce/b2c-dx-mcp@latest --allow-non-ga-tools
46+
### Cursor (Project Scope)
47+
48+
1. Open your project root.
49+
2. Create or edit `.cursor/mcp.json`.
50+
3. Add this entry under `mcpServers` (merge with existing config, do not replace the full file):
51+
52+
```json
53+
"b2c-dx-mcp": {
54+
"command": "npx",
55+
"args": ["-y", "@salesforce/b2c-dx-mcp@latest", "--allow-non-ga-tools"]
56+
}
4757
```
4858

49-
:::
59+
### GitHub Copilot (Project Scope)
60+
61+
1. Open your project root.
62+
2. Create or edit `.vscode/mcp.json`.
63+
3. Add this entry under `servers` (merge with existing config, do not replace the full file):
5064

51-
**Cursor:** [Add to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=b2c-dx-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBzYWxlc2ZvcmNlL2IyYy1keC1tY3BAbGF0ZXN0IiwiLS1wcm9qZWN0LWRpcmVjdG9yeSIsIiR7d29ya3NwYWNlRm9sZGVyfSIsIi0tYWxsb3ctbm9uLWdhLXRvb2xzIl19)
65+
```json
66+
"b2c-dx-mcp": {
67+
"type": "stdio",
68+
"command": "npx",
69+
"args": ["-y", "@salesforce/b2c-dx-mcp@latest", "--allow-non-ga-tools"]
70+
}
71+
```
5272

53-
See the [MCP Server Installation Guide](/mcp/installation) for detailed setup instructions for Claude Code, Cursor, GitHub Copilot, and other MCP clients.
73+
See the [MCP Server Installation Guide](/mcp/installation) for full setup steps and troubleshooting.
5474

5575
## Next Steps
5676

docs/mcp/configuration.md

Lines changed: 111 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,15 @@ description: Configure the B2C DX MCP Server with credentials, flags, environmen
44

55
# Configuration
66

7-
The B2C DX MCP Server uses the same configuration system as the B2C CLI. For MCP, environment variables are set in your MCP client's JSON config (`env` object), not as system environment variables. See the [CLI Configuration guide](../guide/configuration) and [Authentication Setup guide](../guide/authentication) for credential formats and setup details.
7+
The B2C DX MCP Server uses the same configuration system as the B2C CLI.
88

9-
## Configuration Priority
10-
11-
Credentials are resolved in the following priority order (same as the CLI):
12-
13-
1. **Flags** (highest priority) - e.g., `--server`, `--api-key`, `--project`
14-
2. **Environment variables** - Set in MCP client's `env` object
15-
3. **Config files** (lowest priority) - `dw.json` (project-level) and `~/.mobify` (user-level for MRT API key)
16-
17-
**Note:** For MRT API key specifically, `dw.json` (`mrtApiKey` field) takes precedence over `~/.mobify` when both are present.
18-
19-
## Credential Sources
9+
See the [CLI Configuration guide](../guide/configuration) and [Authentication Setup guide](../guide/authentication) for credential formats and setup details.
2010

21-
### Option 1: Config Files (Recommended)
11+
## Credentials
2212

23-
Config files are the recommended approach for managing credentials. They keep credentials out of your MCP client configuration and are automatically loaded from your project.
13+
### `dw.json` (Recommended) {#dw-json}
2414

25-
#### B2C Credentials (`dw.json`)
26-
27-
Create a [`dw.json`](../guide/configuration#configuration-file) file in your project root. The MCP server uses the same format as the CLI. See the [CLI Configuration guide](../guide/configuration#configuration-file) for the complete `dw.json` format, supported fields, and multi-instance configuration.
28-
29-
**Example minimal configuration:**
15+
Create a [`dw.json`](../guide/configuration#configuration-file) file in your project root. The MCP server uses the same format as the CLI and loads it automatically with project-level installation.
3016

3117
```json
3218
{
@@ -40,107 +26,74 @@ Create a [`dw.json`](../guide/configuration#configuration-file) file in your pro
4026
}
4127
```
4228

43-
The server automatically loads this file when using project-level configuration (recommended). With user-level Cursor configuration, ensure `--project-directory "${workspaceFolder}"` is included in the args array. Claude Code and GitHub Copilot automatically detect the project location.
29+
With user-level Cursor configuration, add `--project-directory "${workspaceFolder}"` to the args array so the server can find `dw.json`. Claude Code and GitHub Copilot automatically detect the project location.
30+
31+
See the [CLI Configuration guide](../guide/configuration#configuration-file) for the complete `dw.json` format, supported fields, and multi-instance configuration.
4432

4533
**Required fields per toolset:**
4634

4735
| Toolset | Required Fields |
4836
|---------|----------------|
4937
| **SCAPI** | `short-code`, `tenant-id`, `client-id`, `client-secret` |
5038
| **CARTRIDGES** | `hostname`, `username`, `password` (or OAuth: `hostname`, `client-id`, `client-secret`) |
51-
| **MRT** | `mrtProject` (from `dw.json` `mrtProject` field or `--project` flag), MRT API key (from `dw.json` `mrtApiKey`, `~/.mobify` `api_key`, or `--api-key` flag) |
52-
| **PWAV3** | None (project directory auto-detected with project-level installation) |
53-
| **STOREFRONTNEXT** | None (project directory auto-detected with project-level installation) |
39+
| **MRT** | `mrtProject`, `mrtApiKey` (or `api_key` in `~/.mobify`, or `MRT_API_KEY` env var). `mrtEnvironment` required when deploying. |
40+
| **PWAV3** | None (project directory auto-detected) |
41+
| **STOREFRONTNEXT** | None (project directory auto-detected) |
5442

5543
**Note:** Some tools require specific scopes. See [Configuring Scopes](../guide/authentication#configuring-scopes) in the Authentication Setup guide and individual tool pages for scope requirements.
5644

57-
#### MRT Credentials (`~/.mobify`)
58-
59-
MRT tools require an API key for authentication. MRT API keys are stored in a separate [`~/.mobify`](../guide/configuration#mrt-api-key) file in your home directory.
45+
### `.env` File {#env-file}
6046

61-
Create the `~/.mobify` file manually:
47+
As an alternative to `dw.json`, you can place a `.env` file in your project root. The server loads it automatically at startup via Node.js native `process.loadEnvFile()`.
6248

63-
```json
64-
{
65-
"api_key": "your-mrt-api-key"
66-
}
49+
```bash
50+
SFCC_SERVER=xxx.demandware.net
51+
SFCC_CLIENT_ID=...
52+
SFCC_CLIENT_SECRET=...
53+
SFCC_SHORTCODE=...
54+
SFCC_TENANT_ID=...
6755
```
6856

69-
**File locations:**
70-
- Default: `~/.mobify`
71-
- With `--cloud-origin`: `~/.mobify--{hostname}` (e.g., `~/.mobify--custom.example.com` for `--cloud-origin https://custom.example.com`)
72-
73-
**Note:** The `dw.json` file can include `mrtProject`, `mrtEnvironment`, and `mrtApiKey` for project-level MRT configuration. Alternatively, the API key can be stored in `~/.mobify` (user-level, shared across projects). If both are present, `dw.json` takes precedence. Environment variables and flags can override these values (see [Configuration Priority](#configuration-priority)).
57+
> **Note:** The `.env` file is loaded from the process working directory. Claude Code and GitHub Copilot set cwd to the project root regardless of scope, so `.env` works in all cases. Cursor user-level config (`~/.cursor/mcp.json`) sets cwd to `~`, so `.env` in the project root **will not be found** — use `dw.json` or system environment variables instead. Cursor project-level config (`.cursor/mcp.json`) works as expected.
7458
75-
For complete setup instructions, including how to get your API key, see the [Authentication Guide](../guide/authentication#managed-runtime-api-key).
59+
See the [Environment Variables Reference](#environment-variables-reference) for the complete list of supported variables.
7660

77-
### Option 2: Environment Variables
61+
### MRT Credentials (`~/.mobify`) {#mrt-credentials}
7862

79-
Set environment variables in the `env` object of your MCP client configuration. The MCP server supports the same environment variables as the CLI. See the [CLI Configuration guide](../guide/configuration#environment-variables) for the complete list of supported variables.
80-
81-
> **Note:** Examples below use `mcpServers` (Cursor format). For GitHub Copilot/VS Code, use `servers` instead and add `"type": "stdio"` (see [Installation](./installation#github-copilot)).
63+
MRT tools require an API key. You can include `mrtApiKey`, `mrtProject`, and `mrtEnvironment` in `dw.json` (see [required fields](#dw-json) above), or store the API key in a separate [`~/.mobify`](../guide/configuration#mrt-api-key) file (user-level, shared across projects):
8264

8365
```json
8466
{
85-
"mcpServers": {
86-
"b2c-dx-mcp": {
87-
"command": "npx",
88-
"args": ["-y", "@salesforce/b2c-dx-mcp@latest", "--allow-non-ga-tools"],
89-
"env": {
90-
"SFCC_SERVER": "xxx.demandware.net",
91-
"SFCC_CLIENT_ID": "...",
92-
"SFCC_CLIENT_SECRET": "...",
93-
"SFCC_SHORTCODE": "...",
94-
"SFCC_TENANT_ID": "...",
95-
"MRT_API_KEY": "..."
96-
}
97-
}
98-
}
67+
"api_key": "your-mrt-api-key"
9968
}
10069
```
10170

102-
### Option 3: Flags
71+
**`~/.mobify` file locations:**
72+
- Default: `~/.mobify`
73+
- With `--cloud-origin`: `~/.mobify--{hostname}` (e.g., `~/.mobify--custom.example.com`)
74+
- With `--credentials-file` (or `MRT_CREDENTIALS_FILE`): uses the specified path
10375

104-
Pass credentials directly as command-line flags:
76+
If both `dw.json` and `~/.mobify` contain an API key, `dw.json` takes precedence. For complete setup instructions, see the [Authentication Guide](../guide/authentication#managed-runtime-api-key).
10577

106-
```json
107-
{
108-
"mcpServers": {
109-
"b2c-dx-mcp": {
110-
"command": "npx",
111-
"args": [
112-
"-y",
113-
"@salesforce/b2c-dx-mcp@latest",
114-
"--server",
115-
"xxx.demandware.net",
116-
"--username",
117-
"...",
118-
"--password",
119-
"...",
120-
"--client-id",
121-
"...",
122-
"--client-secret",
123-
"...",
124-
"--allow-non-ga-tools"
125-
]
126-
}
127-
}
128-
}
129-
```
78+
## Configuration Priority
79+
80+
When the same setting is provided in multiple places, the server resolves values in this order:
13081

131-
> **Note:** Flags and environment variables in your MCP client configuration are less secure than config files (`dw.json`), especially if your MCP client configuration is shared or committed to version control. Use `dw.json` (which can be gitignored) for sensitive credentials.
82+
1. **Flags** (highest) — e.g., `--server`, `--api-key` in the `args` array
83+
2. **Environment variables** — via `.env` file, MCP client `env` object, or system environment
84+
3. **Config files** (lowest) — `dw.json` and `~/.mobify`
13285

133-
See the [CLI Configuration guide](../guide/configuration#cli-flags) for complete flag and environment variable documentation.
86+
In practice, you rarely need flags or env vars in `mcp.json``dw.json` and `.env` handle most cases. Flags and the `env` object are available for overrides or CI environments.
13487

13588
## Toolset Selection
13689

13790
### Auto-Discovery (Default)
13891

139-
By default, the server automatically detects your project type and enables relevant toolsets. See [Project Type Detection](./#project-type-detection) for details.
92+
By default, the server automatically detects your project type and enables relevant toolsets. No configuration needed. See [Project Type Detection](./#project-type-detection) for details.
14093

14194
### Manual Selection
14295

143-
Override auto-discovery by specifying toolsets explicitly:
96+
Override auto-discovery with `--toolsets` or `SFCC_TOOLSETS`:
14497

14598
```json
14699
{
@@ -159,15 +112,9 @@ Override auto-discovery by specifying toolsets explicitly:
159112
}
160113
```
161114

162-
**Available toolsets:**
163-
- `CARTRIDGES` - Cartridge deployment and code version management
164-
- `MRT` - Managed Runtime bundle operations
165-
- `PWAV3` - PWA Kit v3 development tools
166-
- `SCAPI` - Salesforce Commerce API discovery
167-
- `STOREFRONTNEXT` - Storefront Next development tools
168-
- `all` - Enable all toolsets
115+
**Available toolsets:** `CARTRIDGES`, `MRT`, `PWAV3`, `SCAPI`, `STOREFRONTNEXT`, `all`
169116

170-
**Note:** The `SCAPI` toolset is always enabled, even if not explicitly specified.
117+
With auto-discovery, the `SCAPI` toolset is always included. When using `--toolsets` or `--tools`, only the specified toolsets/tools are enabled.
171118

172119
### Individual Tool Selection
173120

@@ -183,54 +130,95 @@ Enable specific tools instead of entire toolsets:
183130
}
184131
```
185132

186-
## Logging Configuration
133+
## Logging
187134

188-
### Log Level
189-
190-
Set logging verbosity:
135+
Set logging verbosity with `--log-level` or `SFCC_LOG_LEVEL`:
191136

192137
```json
193138
{
194-
"args": [
195-
"--log-level",
196-
"debug"
197-
]
139+
"args": ["--log-level", "debug"]
198140
}
199141
```
200142

201143
**Available levels:** `trace`, `debug`, `info`, `warn`, `error`, `silent`
202144

203-
### Debug Mode
204-
205-
Enable debug logging (equivalent to `--log-level debug`):
206-
207-
```json
208-
{
209-
"args": [
210-
"--debug"
211-
]
212-
}
213-
```
145+
The `--debug` flag (or `SFCC_DEBUG`) is a shorthand for `--log-level debug`.
214146

215147
## Telemetry
216148

217149
Telemetry is enabled by default and collects anonymous usage data to help improve the developer experience.
218150

219-
### What We Collect
151+
**What we collect:** server lifecycle events, tool usage (which tools and execution time), command metrics, and environment info (platform, Node.js version, package version).
152+
153+
**What we don't collect:** credentials, business data, tool arguments/results, or file contents.
154+
155+
To disable, set either variable in your `.env` file or MCP client `env` object:
156+
157+
| Variable | Description |
158+
|----------|-------------|
159+
| `SFCC_DISABLE_TELEMETRY` | Set to `true` to disable telemetry |
160+
| `SF_DISABLE_TELEMETRY` | Set to `true` to disable telemetry (sf CLI standard) |
161+
162+
## MCP Server Flags Reference {#mcp-server-flags}
163+
164+
Flags specific to the MCP server (in addition to the shared CLI flags in the [CLI Configuration guide](../guide/configuration)):
165+
166+
| Flag | Type | Default | Description |
167+
| ---- | ---- | ------- | ----------- |
168+
| `--toolsets` | string | Auto-detect | Toolsets to enable (comma-separated) |
169+
| `--tools` | string | - | Individual tools to enable (comma-separated) |
170+
| `--allow-non-ga-tools` | boolean | `false` | Enable non-GA (experimental) tools |
171+
172+
Environment variable equivalents for these flags are listed in [MCP Server Environment Variables](#mcp-server-environment-variables).
173+
174+
## Environment Variables Reference {#environment-variables-reference}
175+
176+
These can be set in a `.env` file, the MCP client `env` object, or as system environment variables.
177+
178+
### MCP Server Environment Variables {#mcp-server-environment-variables}
179+
180+
MCP-specific environment variables (flag equivalents):
181+
182+
| Env Variable | Equivalent Flag | Type | Default | Description |
183+
| ------------ | --------------- | ---- | ------- | ----------- |
184+
| `SFCC_TOOLSETS` | `--toolsets` | string | Auto-detect | Toolsets to enable (comma-separated) |
185+
| `SFCC_TOOLS` | `--tools` | string | - | Individual tools to enable (comma-separated) |
186+
| `SFCC_ALLOW_NON_GA_TOOLS` | `--allow-non-ga-tools` | boolean | `false` | Enable non-GA (experimental) tools |
187+
188+
**B2C instance:**
189+
190+
| Variable | Description |
191+
|----------|-------------|
192+
| `SFCC_SERVER` | B2C instance hostname |
193+
| `SFCC_CODE_VERSION` | Code version for deployments |
194+
| `SFCC_USERNAME` | Username for Basic auth (WebDAV) |
195+
| `SFCC_PASSWORD` | Password/access key for Basic auth |
196+
| `SFCC_CLIENT_ID` | OAuth client ID (`SFCC_OAUTH_CLIENT_ID` also supported) |
197+
| `SFCC_CLIENT_SECRET` | OAuth client secret (`SFCC_OAUTH_CLIENT_SECRET` also supported) |
198+
| `SFCC_SHORTCODE` | SCAPI short code |
199+
| `SFCC_TENANT_ID` | Organization/tenant ID |
200+
201+
**MRT:**
220202

221-
- **Server lifecycle events**: When the server starts, stops, or encounters errors
222-
- **Tool usage**: Which tools are called and their execution time (not the arguments or results)
223-
- **Command metrics**: Command duration and success/failure status
224-
- **Environment info**: Platform, architecture, Node.js version, and package version
203+
| Variable | Description |
204+
|----------|-------------|
205+
| `MRT_API_KEY` | MRT API key (`SFCC_MRT_API_KEY` also supported) |
206+
| `MRT_PROJECT` | MRT project slug (`SFCC_MRT_PROJECT` also supported) |
207+
| `MRT_ENVIRONMENT` | Target environment (`SFCC_MRT_ENVIRONMENT` also supported) |
208+
| `MRT_CLOUD_ORIGIN` | MRT API origin URL (`SFCC_MRT_CLOUD_ORIGIN` also supported) |
209+
| `MRT_CREDENTIALS_FILE` | Path to MRT credentials file (overrides `~/.mobify`) |
225210

226-
### What We Don't Collect
211+
**General:**
227212

228-
- **No credentials**: No API keys, passwords, or secrets
229-
- **No business data**: No product data, customer information, or site content
230-
- **No tool arguments**: No input parameters or output results from tool calls
231-
- **No file contents**: No source code, configuration files, or project data
213+
| Variable | Description |
214+
|----------|-------------|
215+
| `SFCC_PROJECT_DIRECTORY` | Project directory (`SFCC_WORKING_DIRECTORY` also supported) |
216+
| `SFCC_CONFIG` | Path to config file |
217+
| `SFCC_INSTANCE` | Instance name from configuration file |
218+
| `SFCC_LOG_LEVEL` | Logging level |
219+
| `SFCC_DEBUG` | Enable debug logging |
232220

233-
To disable telemetry, set `SFCC_DISABLE_TELEMETRY=true` in your MCP client configuration's `env` object.
221+
See the [CLI Configuration guide](../guide/configuration#environment-variables) for the complete list including OAuth and advanced options.
234222

235223
## Next Steps
236224

0 commit comments

Comments
 (0)