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 --scope project

Start a new Claude Code session in your project. Use --scope user instead for all projects.

Manual MCP setup

From your project directory:

bash
claude mcp add --transport stdio --scope project b2c-dx-mcp -- npx -y @salesforce/b2c-dx-mcp@latest

Start a new session. Use --scope user instead for all projects. 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

From your project directory, run:

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

Start a new Gemini CLI session. Use --scope user instead for all projects. 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:132

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:144

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:146

Authentication configuration


config

readonly config: InstanceConfig

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

Instance configuration (hostname, code version)

Accessors

apiBackend

Get Signature

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

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

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

Returns

"ocapi" | "scapi" | "auto"


ocapi

Get Signature

get ocapi(): OcapiClient

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

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:191

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:218

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:154

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

Returns

string