Skip to content

Commit 1485923

Browse files
authored
@W-20592464 SCAPI Schemas List and SCAPI Custom APIs Status MCP tools (#133)
1 parent acf0e05 commit 1485923

File tree

27 files changed

+2751
-153
lines changed

27 files changed

+2751
-153
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@salesforce/b2c-dx-mcp': minor
3+
'@salesforce/b2c-tooling-sdk': minor
4+
---
5+
6+
# Add new MCP tools
7+
8+
- `scapi-schemas-list`: List and fetch SCAPI schemas (standard and custom)
9+
- `scapi-custom-apis-status`: Check custom API endpoint registration status
10+
- `mrt_bundle_push`: Push and deploy a pre-built Storefront Next PWA Kit project to Managed Runtime
11+
- `cartridge_deploy`: Find and deploy cartridges to a B2C Commerce instance via WebDAV
12+
- `storefront_next_development_guidelines`: Get critical architecture rules, coding standards, and best practices for Storefront Next development

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ jobs:
6363
working-directory: packages/b2c-tooling-sdk
6464
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
6565

66-
- name: Run CLI tests
67-
id: cli-test
68-
if: always() && steps.sdk-test.conclusion != 'cancelled'
69-
working-directory: packages/b2c-cli
70-
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
71-
7266
- name: Run MCP tests
7367
id: mcp-test
7468
if: always() && steps.sdk-test.conclusion != 'cancelled'
7569
working-directory: packages/b2c-dx-mcp
7670
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
7771

72+
- name: Run CLI tests
73+
id: cli-test
74+
if: always() && steps.mcp-test.conclusion != 'cancelled'
75+
working-directory: packages/b2c-cli
76+
run: pnpm run pretest && pnpm run test:ci && pnpm run lint
77+
7878
- name: Test Report
7979
uses: dorny/test-reporter@fe45e9537387dac839af0d33ba56eed8e24189e8 # v2.3.0
8080
if: always() && steps.sdk-test.conclusion != 'cancelled'

packages/b2c-cli/src/commands/scapi/custom/status.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,11 @@ import {
1111
toOrganizationId,
1212
type CustomApisComponents,
1313
} from '@salesforce/b2c-tooling-sdk';
14+
import {getApiType} from '@salesforce/b2c-tooling-sdk/schemas';
1415
import {t, withDocs} from '../../../i18n/index.js';
1516

1617
type CustomApiEndpoint = CustomApisComponents['schemas']['CustomApiEndpoint'];
1718

18-
/**
19-
* Maps security scheme to human-readable API type.
20-
*/
21-
function getApiType(securityScheme?: string): string {
22-
switch (securityScheme) {
23-
case 'AmOAuth2': {
24-
return 'Admin';
25-
}
26-
case 'ShopperToken': {
27-
return 'Shopper';
28-
}
29-
default: {
30-
return securityScheme || '-';
31-
}
32-
}
33-
}
34-
3519
/**
3620
* Rolled-up endpoint with sites combined.
3721
* Multiple endpoints with same API/version/path/method are grouped, with siteIds combined.

packages/b2c-dx-mcp/.c8rc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"all": true,
3+
"src": ["src"],
4+
"exclude": ["test/**", "**/*.d.ts", "**/index.ts"],
5+
"reporter": ["text", "text-summary", "html", "lcov"],
6+
"report-dir": "coverage",
7+
"check-coverage": true,
8+
"lines": 80,
9+
"functions": 80,
10+
"branches": 80,
11+
"statements": 80
12+
}

packages/b2c-dx-mcp/.mocharc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"reporter": "spec",
77
"timeout": 60000,
88
"node-option": [
9-
"import=tsx"
9+
"import=tsx",
10+
"conditions=development"
1011
]
1112
}

packages/b2c-dx-mcp/README.md

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,38 @@ The `storefront_next_development_guidelines` tool provides critical architecture
120120
- ✅ "I'm starting a new PWA Kit project. Use the MCP tool to get the development guidelines."
121121
- ✅ "Use the MCP tool to create a new product listing page component in my PWA Kit project."
122122
- ✅ "Use the MCP tool to recommend React hooks for fetching product data in PWA Kit."
123-
- ✅ "Use the MCP tool to explore the SCAPI Shop API endpoints available for my PWA Kit storefront."
124123

125124
##### SCAPI Discovery
126125

127-
**Good prompts:**
128-
- ✅ "Use the MCP tool to discover what SCAPI endpoints are available for product data."
129-
- ✅ "Use the MCP tool to discover custom SCAPI APIs in my B2C instance."
130-
- ✅ "Use the MCP tool to show me all available SCAPI endpoints and their capabilities."
131-
- ✅ "Use the MCP tool to scaffold a new custom SCAPI API for order management."
126+
Use **scapi_schemas_list** for both standard SCAPI (Shop, Admin, Shopper APIs) and custom APIs. Use **scapi_custom_apis_status** for endpoint-level registration status (active/not_registered).
127+
128+
**SCAPI Schemas (tool: `scapi_schemas_list`):**
129+
130+
Discover schema metadata and fetch OpenAPI specs for both standard and custom SCAPI:
131+
132+
**Standard SCAPI:**
133+
- ✅ "Use the MCP tool to list all available SCAPI schemas." → list mode (no includeSchemas).
134+
- ✅ "Use the MCP tool to show me what checkout APIs exist." → list with apiFamily: checkout.
135+
- ✅ "Use the MCP tool to discover SCAPI product endpoints." → list with apiFamily: product.
136+
- ✅ "Use the MCP tool to get the OpenAPI schema for shopper-baskets v1." → fetch with apiFamily, apiName, apiVersion, includeSchemas: true.
137+
- ✅ "Use the MCP tool to show me the full OpenAPI spec for shopper-products v1." → fetch with includeSchemas: true, expandAll: true.
138+
139+
**Custom APIs (use apiFamily: "custom"):**
140+
- ✅ "Use the MCP tool to list custom API definitions." → list with apiFamily: custom.
141+
- ✅ "Use the MCP tool to show me the loyalty-points custom API schema." → apiFamily: custom, apiName: loyalty-points, apiVersion: v1, includeSchemas: true.
142+
143+
**Custom API Endpoint Status (tool: `scapi_custom_apis_status`):**
144+
145+
Get registration status of custom API endpoints deployed on the instance (remote only). Returns individual HTTP endpoints (e.g., GET /hello, POST /items/{id}) with registration status (active/not_registered), one row per endpoint per site. Requires OAuth with `sfcc.custom-apis` scope.
146+
147+
- ✅ "Use the MCP tool to list custom SCAPI endpoints on my instance."
148+
- ✅ "Use the MCP tool to show which custom APIs are active vs not registered."
149+
- ✅ "Use the MCP tool to list custom API endpoints grouped by site." → groupBy: site
150+
- ✅ "Use the MCP tool to list custom API endpoints grouped by type." → groupBy: type
151+
- ✅ "Use the MCP tool to list only active custom API endpoints." → status: active
152+
- ✅ "Use the MCP tool to find custom API endpoints that failed to register." → status: not_registered
153+
- ✅ "Use the MCP tool to show endpoint details with all fields." → extended: true
154+
- ✅ "Use the MCP tool to show only apiName and status for active endpoints." → status: active, columns: "apiName,status"
132155

133156
##### Cartridge Deployment
134157

@@ -157,7 +180,7 @@ Credentials can be provided via **config files** (recommended), **environment va
157180

158181
| Toolset | Required Credentials |
159182
|---------|---------------------|
160-
| **SCAPI** | `hostname` + `client-id` + `client-secret` |
183+
| **SCAPI** | `hostname` + `client-id` + `client-secret` (for `scapi_custom_apis_status`: requires `sfcc.custom-apis` scope) |
161184
| **CARTRIDGES** | `hostname` + `username` + `password` (or OAuth) |
162185
| **MRT** | `api-key` + `project` (optionally `environment`) |
163186
| **PWAV3** | `--working-directory` only (+ MRT config for deployments) |
@@ -264,20 +287,19 @@ PWA Kit v3 development tools for building headless storefronts.
264287
| `pwakit_recommend_hooks` | Recommend appropriate React hooks for PWA Kit use cases |
265288
| `pwakit_run_site_test` | Run site tests for PWA Kit project |
266289
| `pwakit_install_agent_rules` | Install AI agent rules for PWA Kit development |
267-
| `pwakit_explore_scapi_shop_api` | Explore SCAPI Shop API endpoints and capabilities |
268-
| `scapi_discovery` | Discover available SCAPI endpoints and capabilities |
269-
| `scapi_custom_api_discovery` | Discover custom SCAPI API endpoints |
290+
| `scapi_schemas_list` | List or fetch SCAPI schemas (standard and custom). Use apiFamily: "custom" for custom APIs. |
291+
| `scapi_custom_apis_status` | Get registration status of custom API endpoints (active/not_registered). Remote only, requires OAuth. |
270292
| `mrt_bundle_push` | Build, push bundle (optionally deploy) |
271293

272294
#### SCAPI
273295
Salesforce Commerce API discovery and exploration.
274-
- **Status:** 🚧 Placeholder
296+
- **Status:** 🚧 Early Access
275297

276298
| Tool | Description |
277299
|------|-------------|
278-
| `scapi_discovery` | Discover available SCAPI endpoints and capabilities |
279-
| `scapi_customapi_scaffold` | Scaffold a new custom SCAPI API |
280-
| `scapi_custom_api_discovery` | Discover custom SCAPI API endpoints |
300+
| `scapi_schemas_list` | List or fetch SCAPI schemas (standard and custom). Use apiFamily: "custom" for custom APIs. |
301+
| `scapi_custom_apis_status` | Get registration status of custom API endpoints (active/not_registered). Remote only, requires OAuth. |
302+
| `scapi_customapi_scaffold` | Scaffold a new custom SCAPI API (not yet implemented) |
281303

282304
#### STOREFRONTNEXT
283305
Storefront Next development tools for building modern storefronts.
@@ -292,11 +314,11 @@ Storefront Next development tools for building modern storefronts.
292314
| `storefront_next_map_tokens_to_theme` | Map design tokens to Storefront Next theme configuration |
293315
| `storefront_next_design_decorator` | Apply design decorators to Storefront Next components |
294316
| `storefront_next_generate_page_designer_metadata` | Generate Page Designer metadata for Storefront Next components |
295-
| `scapi_discovery` | Discover available SCAPI endpoints and capabilities |
296-
| `scapi_custom_api_discovery` | Discover custom SCAPI API endpoints |
317+
| `scapi_schemas_list` | List or fetch SCAPI schemas (standard and custom). Use apiFamily: "custom" for custom APIs. |
318+
| `scapi_custom_apis_status` | Get registration status of custom API endpoints (active/not_registered). Remote only, requires OAuth. |
297319
| `mrt_bundle_push` | Build, push bundle (optionally deploy) |
298320

299-
> **Note:** Some tools appear in multiple toolsets (e.g., `mrt_bundle_push`, `scapi_discovery`). When using multiple toolsets, tools are automatically deduplicated.
321+
> **Note:** Some tools appear in multiple toolsets (e.g., `mrt_bundle_push`, `scapi_schemas_list`, `scapi_custom_apis_status`). When using multiple toolsets, tools are automatically deduplicated.
300322
301323
## Telemetry
302324

packages/b2c-dx-mcp/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@
8484
"inspect": "mcp-inspector node bin/run.js --toolsets all --allow-non-ga-tools",
8585
"inspect:dev": "mcp-inspector node --conditions development bin/dev.js --toolsets all --allow-non-ga-tools",
8686
"pretest": "tsc --noEmit -p test",
87-
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
87+
"test": "c8 mocha --forbid-only \"test/**/*.test.ts\"",
88+
"test:ci": "c8 mocha --forbid-only --reporter json --reporter-option output=test-results.json \"test/**/*.test.ts\"",
8889
"test:agent": "mocha --forbid-only --reporter min \"test/**/*.test.ts\"",
89-
"test:ci": "mocha --forbid-only --reporter json --reporter-option output=test-results.json \"test/**/*.test.ts\"",
90+
"coverage": "c8 report",
9091
"posttest": "pnpm run lint",
9192
"prepack": "oclif manifest",
9293
"postpack": "shx rm -f oclif.manifest.json"
@@ -95,6 +96,7 @@
9596
"@modelcontextprotocol/sdk": "1.26.0",
9697
"@oclif/core": "4.8.0",
9798
"@salesforce/b2c-tooling-sdk": "workspace:*",
99+
"yaml": "^2.8.1",
98100
"zod": "3.25.76"
99101
},
100102
"devDependencies": {
@@ -107,6 +109,7 @@
107109
"@types/mocha": "^10",
108110
"@types/node": "^22.16.5",
109111
"@types/sinon": "^21.0.0",
112+
"c8": "^10.1.3",
110113
"chai": "^4",
111114
"eslint": "^9",
112115
"eslint-config-oclif": "^6",

0 commit comments

Comments
 (0)