@W-20590941 B2C DX MCP Server Foundation#16
Conversation
| * - `this.parse()` - type-safe flag parsing | ||
| * - `this.error()` - formatted error output | ||
| */ | ||
| export default class McpServerCommand extends Command { |
There was a problem hiding this comment.
Lets try to use the BaseCommand in the SDK: cli/base-command.ts. It contains a number of flags and conventions that are globally useful for debugging and configuration. It also includes a reference to the dw.json file path in the --config flag:
description: 'Path to config file (in dw.json format; defaults to ./dw.json)',
env: 'SFCC_CONFIG',
helpGroup: 'GLOBAL',
}),
Additionally we'll be adding more config conventions there.
| const transport = new StdioServerTransport(); | ||
| await server.connect(transport); | ||
|
|
||
| // Log startup message to stderr (not stdout, which is for MCP protocol) |
There was a problem hiding this comment.
Note that the logging provided in the @b2c-tooling-sdk/logger and @b2c-tooling-sdk/logging/* modules log to stderr by default. So they should be compatible with MCP server STDIO transport.
When using the BaseCommand base OCLIF command class this is initialized using the BaseCommand.configureLogging method. The BaseCommand also overrides the this.log and related methods to funnel through the SDK logger.
We should opt to use this logging convention throughout the tooling. See some of the commands in the b2c-cli package
packages/b2c-dx-mcp/README.md
Outdated
|
|
||
| ## Overview | ||
|
|
||
| This package provides an MCP server that exposes B2C Commerce operations as tools for AI assistants. It wraps functionality from `@salesforce/b2c-tooling-sdk` and is built with [oclif](https://oclif.io/) for robust CLI handling with auto-generated help and environment variable support. |
There was a problem hiding this comment.
I would avoid tightening the MCP strictly with @salesforce/b2c-tooling-sdk. In fact, MCP's functionalities do not fully overlap with b2c-tooling-sdk
There was a problem hiding this comment.
Thanks! I will update this.
packages/b2c-dx-mcp/README.md
Outdated
|
|
||
| ## Configuration | ||
|
|
||
| The server needs B2C Commerce credentials, provided via **environment variables** or a **`dw.json` file**. |
There was a problem hiding this comment.
this should be optional right?
There was a problem hiding this comment.
yes, its optional. I will update it to be clear
packages/b2c-dx-mcp/README.md
Outdated
|
|
||
| ### Option 2: dw.json File | ||
|
|
||
| Create a `dw.json` file (auto-discovered from current directory): |
There was a problem hiding this comment.
please indicate what is necessary to auth?
packages/b2c-dx-mcp/README.md
Outdated
| { | ||
| "mcpServers": { | ||
| "b2c-dx": { | ||
| "command": "npx", |
There was a problem hiding this comment.
This is for the setup after release. We have a section for local setup and development.
There was a problem hiding this comment.
We can add it when it's actually available? Since this is open source, it may be confusing for people who actually try it and get failure.
There was a problem hiding this comment.
That's a good point. I'll update it. Thanks!
packages/b2c-dx-mcp/README.md
Outdated
|
|
||
| | Toolset | Description | | ||
| |---------|-------------| | ||
| | `CARTRIDGES` | Code deployment and version management | |
There was a problem hiding this comment.
should we list tools for each tool set?
There was a problem hiding this comment.
You are right. Its listed in "Available Tools" section which maps tools to tool set.
There was a problem hiding this comment.
When we increase the number of tools in future, it's harder for customers to go through the long list of available tools to figure out what are in each tool set. Therefore, it's easier to list the tools under the tool set (as opposed to list the toolsets for each tool).
There was a problem hiding this comment.
It might be good to have a unique command (or flag (--list-toolsets, --list-tools) for listing toolsets. Instead of relying on documentation alone. (this can be a future thing)
There was a problem hiding this comment.
--list-toolsets, --list-tools and --enable-tools might be useful in the future if we want to allow AI IDE to auto discover and enable tools dynamically.
I re-structured README.md so that it reflects current state to avoid user confusion.
| static flags = { | ||
| // Toolset selection flags | ||
| toolsets: Flags.string({ | ||
| char: "s", |
There was a problem hiding this comment.
Can you remove the shorthand version of these flags? I suspect we will want to update the McpServerCommand to eventually inherit/mix-in flags that support instances/SCAPI (rather than just reading this from dw.json) and -s is assigned to --server, one of the most important flags.
I don't think it's important we have short-hand flags here
There was a problem hiding this comment.
Yes, let me remove short-hand flags. Its not really needed to avoid conflicts.
There was a problem hiding this comment.
@clavery Its removed. Please take another look.
clavery
left a comment
There was a problem hiding this comment.
Approved. There's a few things I want to explore in future PRs (I can help with this):
- We will likely need a BaseCommand that covers instance, MRT, and API use cases. Right now our base commands do not have a "mixin" command like this but MCP needs it. I want this to live in the SDK for other users as well (i will work on this)
- We'll want test coverage checks like the other packages.
Summary
b2c-dx-mcppackage to provide an MCP server foundation that exposes B2C Commerce Developer operations as tools for AI assistants.--toolsets--tools--allow-non-ga-toolsTesting
Follow README.md for detailed setup.
Prerequisites
Setup
MCP Inspector (Web UI)
Run from
packages/b2c-dx-mcp:Open the localhost URL shown in terminal, click Connect, then List Tools.
Cursor
Create
.cursor/mcp.jsonin your project:macOS/Linux:
{ "mcpServers": { "b2c-dx-local": { "command": "/FULL/PATH/TO/packages/b2c-dx-mcp/bin/dev.js", "args": ["--toolsets", "all", "--allow-non-ga-tools"] } } }Windows:
{ "mcpServers": { "b2c-dx-local": { "command": "C:\\FULL\\PATH\\TO\\packages\\b2c-dx-mcp\\bin\\dev.cmd", "args": ["--toolsets", "all", "--allow-non-ga-tools"] } } }Restart Cursor after saving.
Claude Desktop
macOS: Edit
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows: Edit
%APPDATA%\Claude\claude_desktop_config.jsonmacOS/Linux:
{ "mcpServers": { "b2c-dx-local": { "command": "/FULL/PATH/TO/packages/b2c-dx-mcp/bin/dev.js", "args": ["--toolsets", "all", "--allow-non-ga-tools"] } } }Windows:
{ "mcpServers": { "b2c-dx-local": { "command": "C:\\FULL\\PATH\\TO\\packages\\b2c-dx-mcp\\bin\\dev.cmd", "args": ["--toolsets", "all", "--allow-non-ga-tools"] } } }Restart Claude Desktop after saving.
Test Cases
All tests require
--allow-non-ga-toolssince all tools are currently non-GA placeholders.Toolset Selection (
--toolsets)--toolsets all--toolsets CARTRIDGES--toolsets MRT--toolsets PWAV3--toolsets SCAPI--toolsets STOREFRONTNEXT--toolsets CARTRIDGES,MRT--toolsets cartridgesIndividual Tool Selection (
--tools)--tools cartridge_deploy--tools cartridge_deploy,mrt_bundle_push--tools cartridge_deploy,sfnext_design_decorator,mrt_bundle_pushCombination: Toolsets + Tools
--toolsets CARTRIDGES --tools sfnext_design_decorator--toolsets CARTRIDGES,MRT --tools sfnext_design_decorator,scapi_discovery--toolsets CARTRIDGES --tools cartridge_deploy--toolsets all --tools cartridge_deployShared Tool Deduplication
--toolsets MRT,PWAV3--toolsets MRT,PWAV3,STOREFRONTNEXT--toolsets SCAPI,STOREFRONTNEXTValidation (Warnings)
--toolsets INVALID--tools invalid_tool--toolsets CARTRIDGES,INVALID--tools cartridge_deploy,invalid_toolGA/Non-GA Filtering
--toolsets all(without--allow-non-ga-tools)--toolsets all --allow-non-ga-toolsTool Invocation
cartridge_deploy)sfnext_design_decoratorwith message)Expected Tool Counts
pnpm test)pnpm run format)