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 / clients

clients

API clients for B2C Commerce operations.

This module provides typed client classes for interacting with B2C Commerce APIs including WebDAV, OCAPI, SCAPI, and ODS.

Available Clients

  • WebDavClient - File operations via WebDAV
  • OcapiClient - Data API operations via OCAPI (openapi-fetch Client)
  • SlasClient - SLAS Admin API for managing tenants and clients
  • OdsClient - On-Demand Sandbox API for managing developer sandboxes
  • CipClient - B2C Commerce Intelligence (CIP/CCAC) query client
  • CustomApisClient - Custom APIs DX API for retrieving endpoint status
  • ScapiSchemasClient - SCAPI Schemas API for discovering and retrieving OpenAPI schemas

Usage

Note: These clients are typically accessed via B2CInstance rather than instantiated directly. The B2CInstance class handles authentication setup and provides convenient webdav and ocapi getters.

typescript
import { resolveConfig } from '@salesforce/b2c-tooling-sdk/config';

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

// WebDAV operations via instance.webdav
await instance.webdav.put('Cartridges/v1/app.zip', content);

// OCAPI operations via instance.ocapi (openapi-fetch)
const { data } = await instance.ocapi.GET('/sites', {});

Direct Client Usage

For advanced use cases, clients can be instantiated directly:

typescript
import { WebDavClient, createOcapiClient, createSlasClient } from '@salesforce/b2c-tooling-sdk/clients';

const webdav = new WebDavClient('sandbox.demandware.net', authStrategy);
const ocapi = createOcapiClient('sandbox.demandware.net', authStrategy);

// SLAS client for managing SLAS clients and tenants
const slas = createSlasClient({ shortCode: 'kv7kzm78' }, oauthStrategy);

Creating New API Clients

API clients follow a consistent pattern using openapi-fetch for type-safe HTTP requests and openapi-typescript for generating TypeScript types from OpenAPI specifications.

Step 1: Add the OpenAPI Specification

Place the OpenAPI spec (JSON or YAML) in specs/:

packages/b2c-tooling/specs/my-api-v1.yaml

Step 2: Generate TypeScript Types

Add a generation command to package.json and run it:

bash
openapi-typescript specs/my-api-v1.yaml -o src/clients/my-api.generated.ts

Step 3: Create the Client Module

Create a new client file following this pattern:

typescript
// src/clients/my-api.ts
import createClient, { type Client } from 'openapi-fetch';
import type { AuthStrategy } from '../auth/types.js';
import type { paths, components } from './my-api.generated.js';
import { createAuthMiddleware, createLoggingMiddleware } from './middleware.js';

export type { paths, components };
export type MyApiClient = Client<paths>;

export function createMyApiClient(config: MyApiConfig, auth: AuthStrategy): MyApiClient {
  const client = createClient<paths>({
    baseUrl: `https://${config.host}/api/v1`,
  });

  // Add middleware - auth first, logging last (so logging sees complete request)
  client.use(createAuthMiddleware(auth));
  client.use(createLoggingMiddleware('MYAPI'));

  return client;
}

Conventions

  • Factory function: Use createXxxClient() pattern (not classes)
  • Type exports: Re-export paths and components for consumers
  • Client type: Export a type alias XxxClient = Client<paths>
  • Middleware order: Logging first, then auth (auth runs last on request)
  • Log prefix: Use short, uppercase identifier (e.g., 'OCAPI', 'SLAS', 'SCAPI')
  • Generated files: Name as xxx.generated.ts to indicate auto-generation

Classes

Interfaces

Type Aliases

Variables

Functions