-
Notifications
You must be signed in to change notification settings - Fork 5
@W-20590941 B2C DX MCP Server Foundation #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6bfc23b
add b2c-dx-mcp server
yhsieh1 6ec60bc
Merge main into t/commerce/W-20590941/mcp-server
yhsieh1 838d654
update readme and format
yhsieh1 7ebce40
Merge origin/main into t/commerce/W-20590941/mcp-server
yhsieh1 1b1e313
use BaseCommand class and update dev.js run.js to use import tsx
yhsieh1 b527db0
update readme
yhsieh1 5154424
update readme
yhsieh1 fff0f12
remove short hand and update readme
yhsieh1 0b95e99
update readme to clarify tools implementation
yhsieh1 6f25242
clarify readme
yhsieh1 c550da5
update local setup readme
yhsieh1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "watch-extensions": [ | ||
| "ts" | ||
| ], | ||
| "recursive": true, | ||
| "reporter": "spec", | ||
| "timeout": 60000, | ||
| "node-option": [ | ||
| "import=tsx" | ||
| ] | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,283 @@ | ||
| # @salesforce/b2c-dx-mcp | ||
|
|
||
| MCP (Model Context Protocol) server for Salesforce B2C Commerce Cloud developer experience tools. | ||
|
|
||
| > ⚠️ **Active Development**: This package is under active development. All tools are currently **placeholder implementations** that return mock responses. Tool implementations will be added incrementally. | ||
|
|
||
| ## Overview | ||
|
|
||
| This package provides an MCP server that exposes B2C Commerce developer tools for AI assistants. Built with [oclif](https://oclif.io/) for robust CLI handling with auto-generated help and environment variable support. | ||
|
|
||
| ## Usage | ||
|
|
||
| Since the package is not yet published to npm, see the [Development](#development) section for local setup instructions. | ||
|
|
||
| ### Supported Flags | ||
|
|
||
| #### MCP-Specific Flags | ||
|
|
||
| | Flag | Description | | ||
| |------|-------------| | ||
| | `--toolsets` | Comma-separated toolsets to enable (case-insensitive) | | ||
| | `--tools` | Comma-separated individual tools to enable (case-insensitive) | | ||
| | `--allow-non-ga-tools` | Enable experimental (non-GA) tools | | ||
|
|
||
| #### Global Flags (inherited from SDK) | ||
|
|
||
| | Flag | Description | | ||
| |------|-------------| | ||
| | `--config` | Path to dw.json config file (auto-discovered if not provided) | | ||
| | `--instance` | Instance name from configuration file | | ||
| | `--log-level` | Set logging verbosity (trace, debug, info, warn, error, silent) | | ||
| | `--debug` | Enable debug logging | | ||
| | `--json` | Output logs as JSON lines | | ||
| | `--lang` | Language for messages | | ||
|
|
||
| ### Configuration Examples | ||
|
|
||
| ```json | ||
| // Enable specific toolsets | ||
| "args": ["--toolsets", "CARTRIDGES,MRT"] | ||
|
|
||
| // Enable specific tools | ||
| "args": ["--tools", "cartridge_deploy,mrt_bundle_push"] | ||
|
|
||
| // Combine toolsets and tools | ||
| "args": ["--toolsets", "CARTRIDGES", "--tools", "mrt_bundle_push"] | ||
|
|
||
| // Explicit config file path | ||
| "args": ["--toolsets", "all", "--config", "/path/to/dw.json"] | ||
|
|
||
| // Enable experimental tools (required for placeholder tools) | ||
| "args": ["--toolsets", "all", "--allow-non-ga-tools"] | ||
|
|
||
| // Enable debug logging | ||
| "args": ["--toolsets", "all", "--debug"] | ||
| ``` | ||
|
|
||
| ### Available Toolsets and Tools | ||
|
|
||
| Use `--toolsets all` to enable all toolsets, or select specific ones with `--toolsets CARTRIDGES,MRT`. | ||
|
|
||
| > **Note:** All tools are currently placeholder implementations. Use `--allow-non-ga-tools` flag to enable them. | ||
|
|
||
| #### CARTRIDGES | ||
| Code deployment and version management. | ||
| - **Status:** 🚧 Placeholder | ||
|
|
||
| | Tool | Description | | ||
| |------|-------------| | ||
| | `cartridge_deploy` | Deploy cartridges to a B2C Commerce instance | | ||
|
|
||
| #### MRT | ||
| Managed Runtime operations for PWA Kit and Storefront Next deployments. | ||
| - **Status:** 🚧 Placeholder | ||
|
|
||
| | Tool | Description | | ||
| |------|-------------| | ||
| | `mrt_bundle_push` | Build, push bundle (optionally deploy) | | ||
|
|
||
| #### PWAV3 | ||
| PWA Kit v3 development tools for building headless storefronts. | ||
| - **Status:** 🚧 Placeholder | ||
|
|
||
| | Tool | Description | | ||
| |------|-------------| | ||
| | `pwakit_create_storefront` | Create a new PWA Kit storefront project | | ||
| | `pwakit_create_page` | Create a new page component in PWA Kit project | | ||
| | `pwakit_create_component` | Create a new React component in PWA Kit project | | ||
| | `pwakit_get_dev_guidelines` | Get PWA Kit development guidelines and best practices | | ||
| | `pwakit_recommend_hooks` | Recommend appropriate React hooks for PWA Kit use cases | | ||
| | `pwakit_run_site_test` | Run site tests for PWA Kit project | | ||
| | `pwakit_install_agent_rules` | Install AI agent rules for PWA Kit development | | ||
| | `pwakit_explore_scapi_shop_api` | Explore SCAPI Shop API endpoints and capabilities | | ||
| | `scapi_discovery` | Discover available SCAPI endpoints and capabilities | | ||
| | `scapi_custom_api_discovery` | Discover custom SCAPI API endpoints | | ||
| | `mrt_bundle_push` | Build, push bundle (optionally deploy) | | ||
|
|
||
| #### SCAPI | ||
| Salesforce Commerce API discovery and exploration. | ||
| - **Status:** 🚧 Placeholder | ||
|
|
||
| | Tool | Description | | ||
| |------|-------------| | ||
| | `scapi_discovery` | Discover available SCAPI endpoints and capabilities | | ||
| | `scapi_customapi_scaffold` | Scaffold a new custom SCAPI API | | ||
| | `scapi_custom_api_discovery` | Discover custom SCAPI API endpoints | | ||
|
|
||
| #### STOREFRONTNEXT | ||
| Storefront Next development tools for building modern storefronts. | ||
| - **Status:** 🚧 Placeholder | ||
|
|
||
| | Tool | Description | | ||
| |------|-------------| | ||
| | `sfnext_development_guidelines` | Get Storefront Next development guidelines and best practices | | ||
| | `sfnext_site_theming` | Configure and manage site theming for Storefront Next | | ||
| | `sfnext_figma_to_component_workflow` | Convert Figma designs to Storefront Next components | | ||
| | `sfnext_generate_component` | Generate a new Storefront Next component | | ||
| | `sfnext_map_tokens_to_theme` | Map design tokens to Storefront Next theme configuration | | ||
| | `sfnext_design_decorator` | Apply design decorators to Storefront Next components | | ||
| | `sfnext_generate_page_designer_metadata` | Generate Page Designer metadata for Storefront Next components | | ||
| | `scapi_discovery` | Discover available SCAPI endpoints and capabilities | | ||
| | `scapi_custom_api_discovery` | Discover custom SCAPI API endpoints | | ||
| | `mrt_bundle_push` | Build, push bundle (optionally deploy) | | ||
|
|
||
| > **Note:** Some tools appear in multiple toolsets (e.g., `mrt_bundle_push`, `scapi_discovery`). When using multiple toolsets, tools are automatically deduplicated. | ||
|
|
||
|
|
||
| ## Development | ||
|
|
||
| ### Quick Start | ||
|
|
||
| ```bash | ||
| # Install dependencies (from monorepo root) | ||
| pnpm install | ||
|
|
||
| # Navigate to the package directory | ||
| cd packages/b2c-dx-mcp | ||
|
|
||
| # Build the package | ||
| pnpm run build | ||
|
|
||
| # Run tests (includes linting) | ||
| pnpm run test | ||
|
|
||
| # Launch MCP Inspector (builds first, then opens web UI) | ||
| pnpm run inspect | ||
|
|
||
| # Format code | ||
| pnpm run format | ||
|
|
||
| # Run linter only | ||
| pnpm run lint | ||
|
|
||
| # Clean build artifacts | ||
| pnpm run clean | ||
| ``` | ||
|
|
||
| ### Working Directory | ||
|
|
||
| Commands should be run from the `packages/b2c-dx-mcp` directory: | ||
|
|
||
| ```bash | ||
| cd packages/b2c-dx-mcp | ||
| ``` | ||
|
|
||
| Or use pnpm's filter flag from the monorepo root: | ||
|
|
||
| ```bash | ||
| pnpm --filter @salesforce/b2c-dx-mcp run <script> | ||
| ``` | ||
|
|
||
| ### Testing the MCP Server Locally | ||
|
|
||
| #### 1. MCP Inspector | ||
|
|
||
| Use MCP Inspector to browse tools and test them in a web UI: | ||
|
|
||
| ```bash | ||
| pnpm run inspect | ||
| ``` | ||
|
|
||
| This automatically builds before starting the inspector. Open the localhost URL shown in the terminal, click **Connect**, then **List Tools** to see available tools. | ||
|
|
||
| For CLI-based testing: | ||
|
|
||
| ```bash | ||
| # List all tools | ||
| npx mcp-inspector --cli node bin/run.js --toolsets all --allow-non-ga-tools --method tools/list | ||
|
|
||
| # Call a specific tool | ||
| npx mcp-inspector --cli node bin/run.js --toolsets all --allow-non-ga-tools \ | ||
| --method tools/call \ | ||
| --tool-name sfnext_design_decorator | ||
| ``` | ||
|
|
||
| #### 2. IDE Integration | ||
|
|
||
| Configure your IDE to use the local server. Choose development mode (no build required) or production mode (requires build). | ||
|
|
||
| **Development Mode** (recommended for active development - uses TypeScript source directly): | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "b2c-dx-local": { | ||
| "command": "/full/path/to/packages/b2c-dx-mcp/bin/dev.js", | ||
| "args": ["--toolsets", "all", "--allow-non-ga-tools"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| **Production Mode** (uses compiled JavaScript - run `pnpm run build` first): | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "b2c-dx-local": { | ||
| "command": "/full/path/to/packages/b2c-dx-mcp/bin/run.js", | ||
| "args": ["--toolsets", "all", "--allow-non-ga-tools"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| > **Note:** For production mode, run `pnpm run build` after code changes and restart your IDE. Development mode picks up changes automatically. | ||
|
|
||
| #### 3. JSON-RPC via stdin | ||
|
|
||
| Send raw MCP protocol messages: | ||
|
|
||
| ```bash | ||
| # List all tools (--allow-non-ga-tools required for placeholder tools) | ||
| echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node bin/run.js --toolsets all --allow-non-ga-tools | ||
|
|
||
| # Call a specific tool | ||
| echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"cartridge_deploy","arguments":{}}}' | node bin/run.js --toolsets all --allow-non-ga-tools | ||
| ``` | ||
|
|
||
| ### Configuration | ||
|
|
||
| > **Note:** Configuration is not currently required as all tools are placeholder implementations. This section will be relevant once tools are fully implemented. | ||
|
|
||
| Tools that interact with B2C Commerce instances (e.g., MRT, SCAPI, cartridge deployment) require credentials, which can be provided via **environment variables**, a **`.env` file**, a **`dw.json` file**, or the **`--config`** flag. Local tools (e.g., scaffolding, development guidelines) work without configuration. | ||
|
|
||
| **Priority order** (highest to lowest): | ||
| 1. Environment variables (`SFCC_*`) — includes `.env` file if present (shell env vars override `.env`) | ||
| 2. `dw.json` file (auto-discovered or via `--config`) | ||
|
|
||
| #### Option 1: Environment Variables | ||
|
|
||
| Set environment variables directly or create a `.env` file in your project root: | ||
|
|
||
| ```bash | ||
| # .env file or shell exports | ||
| SFCC_HOSTNAME="your-sandbox.demandware.net" | ||
| SFCC_USERNAME="your.username" | ||
| SFCC_PASSWORD="your-access-key" | ||
| SFCC_CLIENT_ID="your-client-id" | ||
| SFCC_CLIENT_SECRET="your-client-secret" | ||
| SFCC_CODE_VERSION="version1" | ||
| ``` | ||
|
|
||
| #### Option 2: dw.json File | ||
|
|
||
| Create a `dw.json` file in your project root (auto-discovered by searching upward from current working directory): | ||
|
|
||
| ```json | ||
| { | ||
| "hostname": "your-sandbox.demandware.net", | ||
| "username": "your.username", | ||
| "password": "your-access-key", | ||
| "client-id": "your-client-id", | ||
| "client-secret": "your-client-secret", | ||
| "code-version": "version1" | ||
| } | ||
| ``` | ||
|
|
||
| > **Note:** Environment variables take precedence over `dw.json` values. | ||
|
|
||
| ## License | ||
|
|
||
| Apache-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| @echo off | ||
|
|
||
| node --conditions development --import tsx "%~dp0\dev" %* | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/usr/bin/env -S node --conditions development --import tsx | ||
| /* | ||
| * Copyright (c) 2025, Salesforce, Inc. | ||
| * SPDX-License-Identifier: Apache-2 | ||
| * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0 | ||
| */ | ||
| /* global process */ | ||
|
|
||
| /** | ||
| * Development entry point for MCP server using oclif. | ||
| * | ||
| * This uses oclif's development mode which: | ||
| * - Uses TypeScript source directly (via tsx loader in shebang) | ||
| * - Supports the 'development' condition for exports | ||
| * - Loads .env file if present for local configuration | ||
| * - Provides better error messages and stack traces | ||
| * | ||
| * Run directly: ./bin/dev.js mcp --toolsets all | ||
| * Or with node: node --conditions development --import tsx bin/dev.js mcp --toolsets all | ||
| */ | ||
|
|
||
| // Load .env file if present (Node.js native support) | ||
| try { | ||
| process.loadEnvFile(); | ||
| } catch { | ||
| // .env file not found or not readable, continue without it | ||
| } | ||
|
|
||
| import {execute} from '@oclif/core'; | ||
|
|
||
| await execute({development: true, dir: import.meta.url}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| @echo off | ||
|
|
||
| node "%~dp0\run" %* | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/usr/bin/env node | ||
| /* | ||
| * Copyright (c) 2025, Salesforce, Inc. | ||
| * SPDX-License-Identifier: Apache-2 | ||
| * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0 | ||
| */ | ||
| /* global process */ | ||
|
|
||
| /** | ||
| * Production entry point for MCP server using oclif. | ||
| * | ||
| * This uses oclif's production mode which: | ||
| * - Uses compiled JavaScript from dist/ | ||
| * - Loads .env file if present for local configuration | ||
| * | ||
| * Run directly: ./bin/run.js mcp --toolsets all | ||
| * Or with node: node bin/run.js mcp --toolsets all | ||
| */ | ||
|
|
||
| // Load .env file if present (Node.js native support) | ||
| try { | ||
| process.loadEnvFile(); | ||
| } catch { | ||
| // .env file not found or not readable, continue without it | ||
| } | ||
|
|
||
| import {execute} from '@oclif/core'; | ||
|
|
||
| await execute({dir: import.meta.url}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.