Install AI Tools

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

Claude

Using Claude Desktop? See Claude Desktop (Cowork) setup.

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.

Codex/ChatGPT

Using the ChatGPT desktop app (ChatGPT Work)? See ChatGPT Work setup.

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. Codex plugins also work in ChatGPT Work.

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.

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

@salesforce/b2c-tooling-sdk / instance / B2CInstance

Class: B2CInstance ​

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:141

Represents a connection to a B2C Commerce instance.

Provides lazy-loaded, typed API clients for WebDAV and OCAPI operations. Authentication is handled automatically based on the configured credentials.

Example ​

ts
// From configuration (recommended)
import { resolveConfig } from '@salesforce/b2c-tooling-sdk/config';

const config = await resolveConfig({
  clientId: process.env.SFCC_CLIENT_ID,
  clientSecret: process.env.SFCC_CLIENT_SECRET,
});
const instance = config.createB2CInstance();

// WebDAV uses Basic auth if available, falls back to OAuth
await instance.webdav.mkcol('Cartridges/v1');

// OCAPI always uses OAuth
const { data } = await instance.ocapi.GET('/sites', {});

Constructors ​

Constructor ​

new B2CInstance(config, auth, options): B2CInstance

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:154

Creates a new B2CInstance.

Parameters ​

config ​

InstanceConfig

Instance configuration (hostname, code version)

auth ​

AuthConfig

Authentication configuration

options ​

B2CInstanceOptions = {}

Optional runtime dependencies, including a pre-resolved OAuth strategy

Returns ​

B2CInstance

Properties ​

auth ​

readonly auth: AuthConfig

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:156

Authentication configuration


config ​

readonly config: InstanceConfig

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:155

Instance configuration (hostname, code version)

Accessors ​

apiBackend ​

Get Signature ​

get apiBackend(): "ocapi" | "scapi" | "auto"

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:172

Backend preference for operations that support both OCAPI and SCAPI. Defaults to 'auto' when not configured.

Returns ​

"ocapi" | "scapi" | "auto"


hasOAuthCredentials ​

Get Signature ​

get hasOAuthCredentials(): boolean

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:220

Whether an API client is available for OCAPI and SCAPI calls (configured OAuth credentials or a caller-provided OAuth strategy). Without one, only WebDAV can be used, with Basic auth or a browser login.

Returns ​

boolean


ocapi ​

Get Signature ​

get ocapi(): OcapiClient

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:277

OCAPI Data API client.

Returns the openapi-fetch client directly with full type safety. Always uses OAuth authentication.

Example ​
ts
const { data, error } = await instance.ocapi.GET('/sites', {});
const { data, error } = await instance.ocapi.PATCH('/code_versions/{code_version_id}', {
  params: { path: { code_version_id: 'v1' } },
  body: { active: true }
});
Returns ​

OcapiClient

The OCAPI Data API client (openapi-fetch Client with full type safety).


scapiClientConfig ​

Get Signature ​

get scapiClientConfig(): ScapiClientConfig | undefined

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:201

SCAPI connection coordinates + a scope-flexible auth strategy, or undefined when this instance cannot reach SCAPI under auto mode.

This is the forward-looking seam for the OCAPI → SCAPI transition: a SCAPI client factory (jobs, sites, scripts, …) needs only a B2CInstance, not a separately-threaded shortCode/tenantId/auth bundle. When OCAPI is eventually removed, the OCAPI accessors disappear and this stays.

Returns undefined unless all of the following hold:

  1. shortCode and tenantId are configured, and
  2. the configured OAuth flow is stateless and scope-flexible — client-credentials (clientId + clientSecret) or JWT Bearer (clientId + cert/key).

Browser user-auth flows (Authorization Code + PKCE and deprecated implicit) are excluded on purpose because SCAPI Admin APIs currently only support system authentication. Fixed-token stored sessions are also excluded because they cannot request the sfcc.* scopes SCAPI needs. This is not an auto-only restriction — because both consumers (the dual-backend factory and the system-job runner) gate on this getter, even explicit --api-backend scapi cannot use SCAPI with implicit/stateful auth; it fails with a clear error naming the flow requirement. SCAPI requires client-credentials or JWT Bearer.

Returns ​

ScapiClientConfig | undefined


webdav ​

Get Signature ​

get webdav(): WebDavClient

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:247

WebDAV client for file operations.

Uses Basic auth if username/password are configured, otherwise falls back to OAuth.

Example ​
ts
await instance.webdav.mkcol('Cartridges/v1');
await instance.webdav.put('Cartridges/v1/app.zip', content);
const entries = await instance.webdav.propfind('Cartridges');
Returns ​

WebDavClient

The lazy-initialized WebDAV client for file operations.


webdavHostname ​

Get Signature ​

get webdavHostname(): string

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:164

The hostname to use for WebDAV operations. Falls back to main hostname if not specified.

Returns ​

string


webdavUsesUserAuth ​

Get Signature ​

get webdavUsesUserAuth(): boolean

Defined in: packages/b2c-tooling-sdk/src/instance/index.ts:230

Whether the WebDAV client authenticates as an Account Manager user (browser login) rather than with Basic auth or an API client token. User tokens are authorized by the user's Business Manager permissions. false until the webdav client has been created.

Returns ​

boolean