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

@salesforce/b2c-tooling-sdk / operations/content / Library

Class: Library ​

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:208

Provides an interface for manipulating B2C Commerce content libraries.

Use the static Library.parse() factory to create instances from library XML. The library tree supports filtering, traversal, mutation, and serialization back to importable XML.

Example ​

typescript
const library = await Library.parse(xmlString);

// Filter to specific pages
library.filter(node => node.id === 'homepage');

// Traverse visible nodes
library.traverse(node => {
  console.log(node.id, node.type);
});

// Serialize back to XML
const xml = await library.toXMLString({ traverseHidden: false });

Properties ​

assetQuery ​

assetQuery: string[] = []

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:209


tree ​

tree: LibraryNode

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:210

Methods ​

filter() ​

filter(predicate, options): this

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:407

Filter the library tree by setting hidden flags on root children.

Parameters ​

predicate ​

FilterCallback

Return true to keep the node visible

options ​

Filter options

recursive? ​

boolean = false

Returns ​

this

this (for chaining)


getContentBlocks() ​

getContentBlocks(): LibraryNode[]

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:320

Returns the library's content blocks (fragments) as a deduplicated catalog.

A content block is a <content> element typed fragment.*. Unlike pages or content assets, fragments are not root-level tree children — they surface wherever a page/component/other-fragment links them. This method scans the full content set (not just the linked tree) so that unlinked blocks are included too, and returns one source-of-truth LibraryNode per block, with its child subtree attached (Layout fragments keep their region children).

Returns ​

LibraryNode[]

One LibraryNode per content block, deduplicated by content-id.

Example ​

typescript
const library = await Library.parse(xml);
for (const block of library.getContentBlocks()) {
  console.log(block.displayName ?? block.id, block.typeId);
}

getTreeString() ​

getTreeString(options): string

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:502

Returns a text tree visualization of the library structure.

Parameters ​

options ​

TreeStringOptions = {}

Tree string options (traversal and optional colorize function)

Returns ​

string

Multi-line tree string


nodes() ​

nodes(options): Generator<LibraryNode>

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:382

Generator-based depth-first iteration of the library tree.

Parameters ​

options ​

TraverseOptions = {}

Traversal options

Returns ​

Generator<LibraryNode>

Yields ​

LibraryNode for each visited node

Example ​

typescript
for (const node of library.nodes()) {
  console.log(node.id, node.type);
}

promoteToRoot() ​

promoteToRoot(node): this

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:433

Move a node from its current parent to the root of the library tree.

Useful for exporting individual components that are normally nested under pages. The node is removed from its original parent's children and added as a root child.

Parameters ​

node ​

LibraryNode

The node to promote

Returns ​

this

this (for chaining)


reset() ​

reset(): this

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:452

Reset all hidden flags, making every node visible again.

Returns ​

this

this (for chaining)


toJSON() ​

toJSON(): Record<string, unknown>

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:561

Returns a JSON-safe representation of the library tree.

Returns ​

Record<string, unknown>


toXMLString() ​

toXMLString(options): Promise<string>

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:470

Serialize the library back to importable XML.

Only includes visible content unless traverseHidden is true.

Parameters ​

options ​

Serialization options

traverseHidden? ​

boolean = true

Returns ​

Promise<string>

XML string


traverse() ​

traverse(callback, options): this

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:349

Depth-first traversal of the library tree.

Parameters ​

callback ​

TraverseCallback

Function called for each visited node

options ​

TraverseOptions = {}

Traversal options

Returns ​

this

this (for chaining)


parse() ​

static parse(libraryXML, options): Promise<Library>

Defined in: packages/b2c-tooling-sdk/src/operations/content/library.ts:230

Parse library XML into a Library tree.

Parameters ​

libraryXML ​

string

Raw XML string of a content library

options ​

LibraryParseOptions = {}

Parse options

Returns ​

Promise<Library>

Parsed Library instance