You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add script debugger support to MCP tools, CLI, and docs
- Add 13 MCP debug tools (debug_start_session, debug_set_breakpoints,
debug_wait_for_stop, debug_get_stack, debug_get_variables,
debug_evaluate, debug_continue, debug_step_over/into/out,
debug_end_session, debug_list_sessions, debug_capture_at_breakpoint)
to CARTRIDGES, SCAPI, and STOREFRONTNEXT toolsets
- Add ServerContext for persistent server-scoped state across MCP tool
invocations (debug sessions, future log watches)
- Add DebugSessionRegistry with TTL cleanup and multi-session support
- Add `b2c debug cli` command with interactive REPL and --rpc mode
for JSONL-over-stdio headless/agent integration
- Add resolveBreakpointPath utility in SDK for flexible path
normalization (server paths, local paths, cartridge-prefixed paths)
- Add debug command docs and b2c-debug agent skill
* Add MCP diagnostics tools doc page and sidebar sub-group
Group debug tools on a single Diagnostics page instead of individual
pages. Add Diagnostics sub-heading under MCP Tools in the sidebar for
future tools like log tailing.
* Group MCP tools sidebar by use case
Organize into Cartridges, SCAPI, PWA Kit, Storefront Next, and
Diagnostics sub-groups.
* Collapse MCP tools sidebar groups by default
* Clarify that debug_wait_for_stop and debug_capture_at_breakpoint block
Make it explicit in tool descriptions and docs that these tools block
until a breakpoint is hit or timeout expires, and that the caller must
trigger a request externally while waiting.
* Improve MCP debug tools based on real-world agent feedback
1. capture_at_breakpoint: add trigger_url parameter so the tool can
fire the HTTP request itself after arming the breakpoint, avoiding
the blocking coordination problem with LLM tool-calling.
2. set_breakpoints: surface warnings when a path cannot be round-trip
mapped back to a local file. Set verified=false for unmapped paths
instead of silently accepting them.
3. Tool descriptions: steer toward the non-blocking workflow
(set_breakpoints → trigger → list_sessions → inspect) rather than
leading with blocking tools.
4. list_sessions: include active breakpoints with resolved server
paths so agents can inspect what's armed on the server.
5. start_session: return cartridge_mappings (name → local path) so
agents can verify cartridge discovery and path mapping.
* Fix resolveBreakpointPath treating absolute local paths as server paths
Absolute local paths like /Users/.../app_mysite/cartridge/controllers/Loyalty.js
start with / and were returned as-is (treated as server paths) before
the source mapper had a chance to map them. Now the source mapper runs
first — if it matches, the local path is correctly converted to a
server path. The / passthrough only applies if the mapper doesn't match.
* Exclude diagnostics tools from MCP coverage threshold
The new debug tools have no unit tests yet (they require mocking the
DebugSessionManager and SDAPI). Excluding from coverage until tests
are added to avoid blocking the draft PR.
* Add tests for diagnostics tools (session registry + tool handlers)
Tests cover DebugSessionRegistry (register, duplicate rejection, get,
destroy, halt waiter cleanup) and tool handlers (list_sessions,
end_session, continue, get_stack, evaluate). Diagnostics tools
excluded from coverage threshold until full coverage is added.
* Fix lint errors in diagnostics test files
* Remove debugger tools from STOREFRONTNEXT toolset
* Add comprehensive tests for diagnostics tools, remove coverage exclusion
Covers all 13 debug tool handlers including set_breakpoints (path
mapping + warnings), get_variables (scope filtering, object_path,
truncation), wait_for_stop (immediate halt, timeout, waiter
resolution), capture_at_breakpoint (full orchestration, trigger_url,
eval errors, timeout), start_session (real fixture cartridge + stubbed
manager), and all step_* variants. Registry tests cover idle cleanup
and disconnect error swallowing.
Coverage is now 99.81% statements/lines, 94.65% branches, 98.94%
functions — meeting all thresholds without excluding diagnostics.
* Refactor debug MCP tools: shared projections, registry helpers, doc updates
Tier 1 cleanup based on PR review feedback (patricksullivansf, yhsieh1)
and self-review.
DRY:
- Extract shared projection helpers to SDK (projections.ts):
truncateValue, isPrimitiveType, projectFrame, projectVariable,
projectBreakpoint, projectThreadLocation, plus exported types
MappedFrame/MappedVariable/MappedBreakpoint/MappedLocation. Used by
both MCP debug tools and CLI RPC mode — eliminates 5+ copies of the
same projection code and the MAX_VALUE_LENGTH/PRIMITIVE_TYPES
constants.
- Add getSessionEntry/getRegistry helpers to session-registry. Replace
the 4-line "registry not available" + getSessionOrThrow boilerplate
in 11 tools.
- Move halt-waiter promise pattern into DebugSessionRegistry.waitForHalt.
Used by debug_wait_for_stop and debug_capture_at_breakpoint instead
of duplicating the promise/timer/cleanup logic.
- Replace step-action switch with a lookup map.
API:
- DebugSessionRegistry.registerSession now takes an options object
(yhsieh1 nit) instead of 5 positional parameters.
Docs:
- Add "Recovery from broken or orphaned sessions" section to
docs/mcp/tools/diagnostics.md (patricksullivansf concern).
- Link to main authentication and configuration guides.
- Add JSDoc to ServerContext explaining stdio-per-client isolation
vs shared transport caveats (patricksullivansf concern).
Tool descriptions (yhsieh1 audit):
- Drop user-facing prose, sharpen for agent consumption.
- debug_start_session: explicitly mention SFRA controllers, custom API
scripts, hooks, jobs as use cases.
- debug_end_session: IMPORTANT call-out to always end sessions.
Coverage stays at 99.81% statements/lines, 94.81% branches,
98.93% functions — all above thresholds.
* Align diagnostics auth section with other MCP tool docs
Match the cartridge-deploy.md pattern: structured Required block,
Configuration priority line, link to ../configuration (MCP config)
and ../../guide/authentication#webdav-access (main auth guide
with WebDAV anchor).
Add `b2c debug cli` command for interactive terminal-based script debugging. Includes a REPL with commands for breakpoints, stepping, variable inspection, and expression evaluation. Use `--rpc` for JSONL-over-stdio mode suitable for headless scripts and agents.
Add `ServerContext` for persistent server-scoped state across MCP tool invocations. Enables stateful tools (debug sessions, log watches) while preserving per-call config reloading for existing tools.
Add `resolveBreakpointPath` utility that normalizes user-provided file paths to SDAPI script paths. Accepts server paths, absolute/relative local paths, and cartridge-name-prefixed paths with helpful error messages on failure.
Copy file name to clipboardExpand all lines: docs/cli/debug.md
+218-5Lines changed: 218 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,13 @@
1
1
---
2
-
description: Start a DAP debug adapter for B2C Commerce server-side script debugging.
2
+
description: DAP debug adapter, interactive REPL, and JSONL RPC mode for B2C Commerce server-side script debugging.
3
3
---
4
4
5
-
# Debug Command
5
+
# Debug Commands
6
6
7
-
The `b2c debug` command launches a [Debug Adapter Protocol (DAP)](https://microsoft.github.io/debug-adapter-protocol/) adapter that bridges your IDE to the B2C Commerce script debugger. It's designed to be invoked by an IDE (VS Code, JetBrains, etc.) over stdio, not run directly in a shell.
7
+
Commands for connecting to the B2C Commerce Script Debugger API (SDAPI) to set breakpoints, inspect variables, and step through server-side code.
8
+
9
+
-**`b2c debug`** — Debug Adapter Protocol (DAP) adapter for IDE integrations (VS Code, JetBrains, etc.).
10
+
-**`b2c debug cli`** — interactive terminal REPL, or JSONL-over-stdio RPC mode for headless scripts and agents.
8
11
9
12
## Authentication
10
13
@@ -14,11 +17,15 @@ The script debugger uses **Basic auth** (Business Manager username and password)
The script debugger must also be enabled on the instance: Business Manager > Administration > Development Configuration > Script Debugger > Enable.
21
+
17
22
See the [Authentication Guide](/guide/authentication) for details.
18
23
24
+
---
25
+
19
26
## b2c debug
20
27
21
-
Start the DAP adapter for the configured B2C instance.
28
+
The `b2c debug` command launches a [Debug Adapter Protocol (DAP)](https://microsoft.github.io/debug-adapter-protocol/) adapter that bridges your IDE to the B2C Commerce script debugger. It's designed to be invoked by an IDE over stdio, not run directly in a shell.
Most IDEs spawn DAP adapters automatically based on a launch configuration. The adapter speaks DAP over **stdin/stdout**, so direct shell invocation will appear to hang — that's expected. Configure your IDE's debug launcher to invoke `b2c debug` and supply the appropriate environment.
54
61
55
-
## Notes
62
+
###Notes
56
63
57
64
- A warning is emitted if no cartridges are found at `--cartridge-path`.
58
65
- Source maps are derived from the discovered cartridge layout; ensure your local cartridge tree matches what's deployed to the instance, otherwise breakpoints may not bind.
59
66
- The adapter exits when its stdin stream closes.
67
+
68
+
---
69
+
70
+
## b2c debug cli
71
+
72
+
Start an interactive CLI debug session with a REPL interface. Provides a terminal-based debugging experience without requiring a DAP client. Add `--rpc` to switch to JSONL-over-stdio mode for headless scripts and agents.
When started with `--rpc`, the debug CLI runs as a JSONL-over-stdio RPC server. This enables headless scripts, agents, and other tools to drive the debugger programmatically.
158
+
159
+
### Protocol
160
+
161
+
-**Input** (stdin): One JSON object per line (JSONL)
162
+
-**Output** (stdout): One JSON object per line — either a response or an async event
0 commit comments