Install AI Tools

B2C Commerce tools, documentation, and skills for your assistant.

Claude

Install the plugin Recommended

bash
claude plugin marketplace add SalesforceCommerceCloud/b2c-developer-tooling
claude plugin install b2c-dx-mcp@b2c-developer-tooling

Start a new Claude Code session. To install for the current project only, run it from your project directory with --scope project.

Manual MCP setup
bash
claude mcp add --transport stdio --scope user b2c-dx-mcp -- npx -y @salesforce/b2c-dx-mcp@latest

Start a new session. To configure the current project only, run it from your project directory with --scope project. See Claude Code MCP setup.

Claude Desktop setup

Codex

Install the plugin Recommended

bash
codex plugin marketplace add SalesforceCommerceCloud/b2c-developer-tooling
codex plugin add b2c-dx-mcp@b2c-developer-tooling

Start a new Codex session in your project. This setup also works with the Codex IDE extension and the ChatGPT Work desktop app.

Manual MCP setup
bash
codex mcp add b2c-dx-mcp -- npx -y @salesforce/b2c-dx-mcp@latest

Or add this to ~/.codex/config.toml (or $CODEX_HOME/config.toml if customized):

toml
[mcp_servers.b2c-dx-mcp]
command = "npx"
args = ["-y", "@salesforce/b2c-dx-mcp@latest"]

Start a new session. See Codex MCP configuration.

ChatGPT online setup

VS Code

Install the plugin Recommended

  1. Open the Command Palette (Cmd/Ctrl+Shift+P) and run Chat: Install Plugin from Source.
  2. Enter SalesforceCommerceCloud/b2c-developer-tooling.
  3. Select b2c-dx-mcp and follow the installation prompts.
  4. Start a new chat in GitHub Copilot.
Manual MCP setup

Add this to .vscode/mcp.json in your workspace:

json
{
  "servers": {
    "b2c-dx-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@salesforce/b2c-dx-mcp@latest"]
    }
  }
}

See VS Code MCP setup.

Copilot CLI setup

Cursor

Reload the MCP server in Cursor after installation.

Manual MCP setup

Add this to .cursor/mcp.json in your project:

json
{
  "mcpServers": {
    "b2c-dx-mcp": {
      "command": "npx",
      "args": ["-y", "@salesforce/b2c-dx-mcp@latest"]
    }
  }
}

For all projects, use ~/.cursor/mcp.json instead.

See Cursor's MCP documentation.

OpenCode

Add this to opencode.json in your project:

json
{
  "mcp": {
    "b2c-dx-mcp": {
      "type": "local",
      "command": ["npx", "-y", "@salesforce/b2c-dx-mcp@latest"],
      "enabled": true
    }
  }
}

Restart OpenCode. For all projects, use ~/.config/opencode/opencode.json. See OpenCode MCP setup.

Gemini

Run:

bash
gemini mcp add --scope user b2c-dx-mcp -- npx -y @salesforce/b2c-dx-mcp@latest

Start a new Gemini CLI session. To configure the current project only, run it from your project directory with --scope project. See Gemini CLI MCP setup.

No separate skills plugins needed.

Other clients and manual setup →
Skip to content
View as Markdown
View as Markdown

b2c_tooling_sdk.operations.code ​

Code deployment operations for B2C Commerce.

Mirrors src/operations/code/index.ts. Provides functions for managing cartridge code versions on B2C Commerce instances via WebDAV and OCAPI/SCAPI.

Cartridge discovery:

Code versions:

Deployment:

Download:

Classes ​

CartridgeMapping ​

python
class CartridgeMapping

A discovered cartridge in the local filesystem.

Fields

NameType
namestr
srcstr
deststr

CodeVersion ​

python
class CodeVersion(BaseModel)

<p>Document representing a code version</p>

Fields

NameTypeDefault
activation_timeAwareDatetime | NoneField(None, description='The code version activation time.')
activebool | None
cartridgeslist[str] | None
compatibility_modestr | None
idstr | NoneField(None, description='The code version id.')
last_modification_timeAwareDatetime | None
rollbackbool | None
total_sizeint | None
web_dav_urlstr | None

CodeVersionActivationResult ​

python
class CodeVersionActivationResult

Result of requesting activation of a code version.

Fields

NameType
already_activebool

CodeVersionInfo ​

python
class CodeVersionInfo

A code version, normalized across the OCAPI and SCAPI representations.

activation_time/last_modification_time are kept as ISO-8601 strings (matching the TypeScript string fields) even though the underlying generated Pydantic models parse them as datetime — each backend converts via .isoformat() at the mapping boundary.

Fields

NameTypeDefault
idstr
activebool | NoneNone
cartridgeslist[str] | NoneNone
compatibility_modestr | NoneNone
activation_timestr | NoneNone
last_modification_timestr | NoneNone
rollbackbool | NoneNone
total_sizeint | NoneNone
web_dav_urlstr | NoneNone
rawAnyNone

CodeVersionResult ​

python
class CodeVersionResult(BaseModel)

<p>Result document containing an array of code versions.</p>

Fields

NameTypeDefault
countint | NoneField(None, description='The number of returned documents.')
datalist[CodeVersion] | NoneField(None, description='The array of code versions')
nextstr | NoneField(None, description='The URL of the next result page.')
previousstr | None
selectstr | None
startint | None
totalint | NoneField(None, description='The total number of documents.')

DeployOptions ​

python
class DeployOptions(FindCartridgesOptions)

Options for deploying cartridges.

Fields

NameTypeDefault
scripts_backendScriptsBackend | NoneNone
activateboolFalse
reloadboolFalse
deleteboolFalse
on_progressCallable[[UploadProgressInfo], None] | NoneNone

DeployResult ​

python
class DeployResult

Result of a cartridge deployment.

Fields

NameType
cartridgeslist[CartridgeMapping]
code_versionstr
activatedbool
reloadedbool

DownloadOptions ​

python
class DownloadOptions

Options for downloading cartridges.

Fields

NameTypeDefault
scripts_backendScriptsBackend | NoneNone
includelist[str]field(default_factory=list)
excludelist[str]field(default_factory=list)
mirrordict[str, str] | NoneNone
on_progressCallable[[DownloadProgressInfo], None] | NoneNone

DownloadProgressInfo ​

python
class DownloadProgressInfo

Progress info passed to the download on_progress callback.

Fields

NameType
phaseDownloadPhase
elapsed_secondsint

DownloadResult ​

python
class DownloadResult

Result of a cartridge download.

Fields

NameType
cartridgeslist[str]
code_versionstr
output_directorystr

FileChange ​

python
class FileChange

A file to upload or delete, with source and destination paths.

Fields

NameType
srcstr
deststr

FindCartridgesOptions ​

python
class FindCartridgesOptions

Options for find_cartridges.

Fields

NameTypeDefault
includelist[str]field(default_factory=list)
excludelist[str]field(default_factory=list)
max_depthint | NoneNone
first_match_onlyboolFalse

OcapiScriptsBackend ​

python
class OcapiScriptsBackend

Code-version operations against the legacy OCAPI Data API.

Fields

NameType
nameLiteral['ocapi']

ScapiScriptsBackend ​

python
class ScapiScriptsBackend

Code-version operations against the SCAPI Scripts DX API.

Fields

NameType
nameLiteral['scapi']

ScriptsBackend ​

python
class ScriptsBackend(BackendBase, Protocol)

Backend-agnostic interface for code-version operations.

Implemented by OcapiScriptsBackend and ScapiScriptsBackend.

UploadFilesOptions ​

python
class UploadFilesOptions

Callbacks for file upload/delete operations.

Fields

NameTypeDefault
on_uploadCallable[[list[str]], None] | NoneNone
on_deleteCallable[[list[str]], None] | NoneNone
on_errorCallable[[Exception], None] | NoneNone

UploadOptions ​

python
class UploadOptions

Options for upload progress reporting.

Fields

NameTypeDefault
on_progressCallable[[UploadProgressInfo], None] | NoneNone

UploadProgressInfo ​

python
class UploadProgressInfo

Progress info passed to the upload on_progress callback.

Fields

NameType
phaseUploadPhase
elapsed_secondsint

WatchOptions ​

python
class WatchOptions(FindCartridgesOptions)

Options for watching cartridges.

Fields

NameTypeDefault
scripts_backendScriptsBackend | NoneNone
debounce_time_msint_DEFAULT_DEBOUNCE_MS
on_uploadCallable[[list[str]], None] | NoneNone
on_deleteCallable[[list[str]], None] | NoneNone
on_errorCallable[[Exception], None] | NoneNone
poll_interval_secondsfloat_DEFAULT_POLL_INTERVAL_SECONDS

WatchResult ​

python
class WatchResult

Result of starting a watcher.

Fields

NameType
cartridgeslist[CartridgeMapping]
code_versionstr
stopCallable[[], Awaitable[None]]

Functions ​

activate_code_version ​

python
async def activate_code_version(instance: B2CInstance, code_version_id: str) -> CodeVersionActivationResult

Activate a code version.

Idempotent: if OCAPI reports the code version is already active, this returns already_active=True rather than raising.

create_code_version ​

python
async def create_code_version(instance: B2CInstance, code_version_id: str) -> None

Create a new (empty) code version.

create_scripts_backend ​

python
def create_scripts_backend(config: ScriptsBackendConfig) -> ScriptsBackend

Create a code-version backend, choosing SCAPI or OCAPI per config.

Delegates to create_dual_backend.

delete_cartridges ​

python
async def delete_cartridges(instance: B2CInstance, cartridges: list[CartridgeMapping]) -> None

Delete cartridges from an instance via WebDAV.

Low-level function that deletes cartridge directories from the specified code version. Errors are silently ignored for cartridges that don't exist.

Requires instance.config.code_version to be set.

Raises

  • RuntimeError — if the instance has no code version configured.

delete_code_version ​

python
async def delete_code_version(instance: B2CInstance, code_version_id: str) -> None

Delete a code version.

download_cartridges ​

python
async def download_cartridges(instance: B2CInstance, output_directory: str, options: DownloadOptions | None = None) -> DownloadResult

Download cartridges from an instance via WebDAV.

When include specifies cartridges, each is downloaded individually using per-cartridge server-side zipping for efficiency. When downloading all cartridges (no include filter), the entire code version is zipped at once.

If instance.config.code_version is not set, attempts to discover the active code version via the scripts backend. If that also fails, raises.

download_single_cartridge ​

python
async def download_single_cartridge(instance: B2CInstance, code_version: str, cartridge_name: str, output_path: str, on_progress: Callable[[DownloadProgressInfo], None] | None = None) -> None

Download a single cartridge from an instance via WebDAV.

More efficient than downloading the entire code version when only one cartridge is needed, since it ZIPs only the cartridge subdirectory server-side.

file_to_cartridge_path ​

python
def file_to_cartridge_path(absolute_path: str, cartridges: list[CartridgeMapping]) -> FileChange | None

Map an absolute file path to its cartridge-relative destination.

Parameters

NameTypeDescription
absolute_pathstrThe absolute path to a file.
cartridgeslist[CartridgeMapping]The list of discovered cartridge mappings.

Returns: The file change with src/dest, or None if the path is not inside any cartridge.

find_and_deploy_cartridges ​

python
async def find_and_deploy_cartridges(instance: B2CInstance, directory: str, options: DeployOptions | None = None) -> DeployResult

Find and deploy cartridges from a directory to an instance.

High-level function that orchestrates the deployment process:

  1. Finds cartridges in the specified directory (by .project files).
  2. Applies include/exclude filters.
  3. Optionally deletes existing cartridges first.
  4. Creates a zip archive and uploads via WebDAV.
  5. Optionally activates or reloads the code version.

Requires instance.config.code_version to be set.

Raises

  • RuntimeError — if code version is not set, no cartridges are found, or deployment fails.

find_cartridges ​

python
def find_cartridges(directory: str | None = None, options: FindCartridgesOptions | None = None) -> list[CartridgeMapping]

Find cartridges recursively in a directory.

Cartridges are identified by the presence of a .project file (Eclipse project marker commonly used in SFCC development).

Parameters

NameTypeDescription
directorystr | NoneDirectory to search for cartridges (defaults to the current working directory).
optionsFindCartridgesOptions | NoneFilter options for including/excluding cartridges.

Returns: List of discovered cartridge mappings.

get_active_code_version ​

python
async def get_active_code_version(instance: B2CInstance) -> CodeVersion | None

Return the currently active code version, or None if none is active.

list_code_versions ​

python
async def list_code_versions(instance: B2CInstance) -> list[CodeVersion]

List all code versions on the instance.

reload_code_version ​

python
async def reload_code_version(backend: ScriptsBackend, code_version_id: str | None = None) -> None

Reload (re-activate) a code version using a toggle-activate technique.

Activates an alternate version, then re-activates the target. This forces the instance to reload the code (rebuild caches, re-register custom APIs, etc.). Works on top of any ScriptsBackend since it only uses list/activate primitives.

Parameters

NameTypeDescription
code_version_idstr | NoneCode version to reload (defaults to the current active version).

Raises

  • RuntimeError — if no code version is specified and none is active, or if the target is already active and no alternate code version exists to toggle through.

upload_cartridges ​

python
async def upload_cartridges(instance: B2CInstance, cartridges: list[CartridgeMapping], options: UploadOptions | None = None) -> None

Upload cartridges to an instance via WebDAV.

Low-level upload function that:

  1. Creates a zip archive of the cartridges.
  2. Uploads it to WebDAV.
  3. Unzips on the server.
  4. Cleans up the temporary zip file.

Requires instance.config.code_version to be set.

Raises

  • RuntimeError — if code version is not set or no cartridges are given.

watch_cartridges ​

python
async def watch_cartridges(instance: B2CInstance, directory: str, options: WatchOptions | None = None) -> WatchResult

Watch cartridge directories and sync changes to an instance.

  1. Finds cartridges in the specified directory.
  2. Polls those directories for changes (see module docstring for why polling rather than native OS watching is used).
  3. Batches file changes (debounced) and uploads them via WebDAV.
  4. Handles file deletions.

Raises

  • RuntimeError — if no code version is configured and none is active, or if no cartridges are found in directory.

Attributes ​

ScapiScriptsBackendConfig ​

python
ScapiScriptsBackendConfig = ScapiBackendCtorConfig

ScriptsBackendConfig ​

python
ScriptsBackendConfig = DualBackendConfig