@salesforce/b2c-dx-mcp 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -195,7 +195,8 @@ export default class McpServerCommand extends BaseCommand {
195
195
  }),
196
196
  'docs-topics': Flags.string({
197
197
  description: 'Limit the documentation exposed by the docs tools to these categories (comma-separated allowlist). ' +
198
- 'Options: script-api, job-step, commerce-api, pwa-kit-managed-runtime, sfnext, sfra, b2c-commerce, tooling. ' +
198
+ 'Options: script-api, job-step, commerce-api, pwa-kit-managed-runtime, sfnext, sfra, b2c-commerce, tooling, ' +
199
+ 'help-admin, help-merchant. ' +
199
200
  'Bounds the whole docs corpus; per-call category/storefront narrow within it. Unknown names are ignored.',
200
201
  env: 'SFCC_DOCS_TOPICS',
201
202
  }),
@@ -308,8 +309,10 @@ export default class McpServerCommand extends BaseCommand {
308
309
  configPath: this.flags.config,
309
310
  // Project directory for auto-discovery. oclif handles flag with env fallback.
310
311
  projectDirectory: this.flags['project-directory'],
311
- // Docs topic allowlist (bounds the docs corpus at startup).
312
- docsTopics: this.flags['docs-topics'],
312
+ // Docs topic allowlist (bounds the docs corpus at startup). Flag first
313
+ // (--docs-topics / SFCC_DOCS_TOPICS), else config `docsCategories`
314
+ // (dw.json `docs-categories`, SFCC_DOCS_CATEGORIES, package.json).
315
+ docsTopics: this.flags['docs-topics'] ?? this.resolvedConfig?.values.docsCategories?.join(','),
313
316
  };
314
317
  // Add toolsets to telemetry attributes
315
318
  if (this.telemetry && startupFlags.toolsets) {
@@ -1,4 +1,5 @@
1
1
  import { type DocCategory } from '@salesforce/b2c-tooling-sdk/docs';
2
+ import type { ProjectType } from '@salesforce/b2c-tooling-sdk/discovery';
2
3
  import type { McpTool } from '../../utils/index.js';
3
4
  import type { Services } from '../../services.js';
4
- export declare function createDocsReadTool(loadServices: () => Promise<Services> | Services, enabledCategories?: readonly DocCategory[]): McpTool;
5
+ export declare function createDocsReadTool(loadServices: () => Promise<Services> | Services, enabledCategories?: readonly DocCategory[], detectedWorkspaces?: readonly ProjectType[]): McpTool;
@@ -9,14 +9,15 @@ import { createToolAdapter, errorResult, jsonResult } from '../adapter.js';
9
9
  import { enabledCategoriesNote } from './topics.js';
10
10
  /** Default maximum characters of content returned per read call, to bound the inline payload. */
11
11
  const DEFAULT_MAX_LENGTH = 12_000;
12
- export function createDocsReadTool(loadServices, enabledCategories) {
12
+ export function createDocsReadTool(loadServices, enabledCategories, detectedWorkspaces = []) {
13
13
  return createToolAdapter({
14
14
  name: 'docs_read',
15
- description: 'Read B2C Commerce documentation (markdown) for a class, module, job step, or guide. ' +
15
+ description: 'Read B2C Commerce documentation (markdown) for a class, module, job step, guide, or Help article. ' +
16
16
  'Accepts an exact id (e.g. "dw.catalog.ProductMgr", "sfnext/sfnext-get-started") or a fuzzy ' +
17
- 'query — best match wins. Script API / job-step content is bundled; Developer Center guide ' +
18
- 'content is fetched from its published URL on demand (with a summary/headings fallback if the ' +
19
- 'network is unavailable). If you do not know the id, call docs_search first. Long docs are ' +
17
+ 'query — best match wins (a fuzzy query favors the detected workspace, matching docs_search). ' +
18
+ 'Job-step content is bundled; Script API, Developer Center guide, and Salesforce Help content is ' +
19
+ 'fetched from its published URL on demand and cached locally (with a summary/headings fallback if ' +
20
+ 'the network is unavailable). If you do not know the id, call docs_search first. Long docs are ' +
20
21
  'truncated to maxLength chars; page with offset when truncated=true. The returned entry ' +
21
22
  'includes the canonical url for citation.' +
22
23
  enabledCategoriesNote(enabledCategories),
@@ -40,7 +41,12 @@ export function createDocsReadTool(loadServices, enabledCategories) {
40
41
  .describe(`Maximum characters of content to return. Defaults to ${DEFAULT_MAX_LENGTH}.`),
41
42
  },
42
43
  async execute(args) {
43
- const found = await readDocByQuery(args.query, { enabledCategories });
44
+ // Favor the detected workspace when resolving a fuzzy query so a read
45
+ // picks the same top hit docs_search ranks first. Exact id matches
46
+ // short-circuit inside readDocByQuery before searching, so the boost
47
+ // only affects fuzzy resolution.
48
+ const workspace = detectedWorkspaces.length > 0 ? [...detectedWorkspaces] : undefined;
49
+ const found = await readDocByQuery(args.query, { enabledCategories, workspace });
44
50
  if (!found)
45
51
  return null;
46
52
  const totalLength = found.content.length;
@@ -16,7 +16,7 @@ export function createDocsTools(loadServices, context = {}) {
16
16
  const { detectedWorkspaces = [], enabledCategories } = context;
17
17
  return [
18
18
  createDocsSearchTool(loadServices, detectedWorkspaces, enabledCategories),
19
- createDocsReadTool(loadServices, enabledCategories),
19
+ createDocsReadTool(loadServices, enabledCategories, detectedWorkspaces),
20
20
  createDocsListTool(loadServices, detectedWorkspaces, enabledCategories),
21
21
  createDocsSchemaSearchTool(loadServices),
22
22
  createDocsSchemaReadTool(loadServices),
@@ -403,7 +403,7 @@
403
403
  "type": "option"
404
404
  },
405
405
  "docs-topics": {
406
- "description": "Limit the documentation exposed by the docs tools to these categories (comma-separated allowlist). Options: script-api, job-step, commerce-api, pwa-kit-managed-runtime, sfnext, sfra, b2c-commerce, tooling. Bounds the whole docs corpus; per-call category/storefront narrow within it. Unknown names are ignored.",
406
+ "description": "Limit the documentation exposed by the docs tools to these categories (comma-separated allowlist). Options: script-api, job-step, commerce-api, pwa-kit-managed-runtime, sfnext, sfra, b2c-commerce, tooling, help-admin, help-merchant. Bounds the whole docs corpus; per-call category/storefront narrow within it. Unknown names are ignored.",
407
407
  "env": "SFCC_DOCS_TOPICS",
408
408
  "name": "docs-topics",
409
409
  "hasDynamicHelp": false,
@@ -428,5 +428,5 @@
428
428
  "enableJsonFlag": false
429
429
  }
430
430
  },
431
- "version": "1.7.0"
431
+ "version": "1.8.0"
432
432
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/b2c-dx-mcp",
3
3
  "description": "MCP server for B2C Commerce developer experience tools",
4
- "version": "1.7.0",
4
+ "version": "1.8.0",
5
5
  "author": "Salesforce",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "SalesforceCommerceCloud/b2c-developer-tooling",
@@ -80,7 +80,7 @@
80
80
  "yaml": "2.9.0",
81
81
  "postcss": "8.5.15",
82
82
  "zod": "3.25.76",
83
- "@salesforce/b2c-tooling-sdk": "1.19.1"
83
+ "@salesforce/b2c-tooling-sdk": "1.20.0"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@eslint/compat": "^1",