Add script debugger MCP tools, CLI REPL, and RPC mode#395
Draft
Add script debugger MCP tools, CLI REPL, and RPC mode#395
Conversation
- 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
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.
Organize into Cartridges, SCAPI, PWA Kit, Storefront Next, and Diagnostics sub-groups.
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.
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.
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
b2c debug cli— interactive REPL for terminal-based debugging with--rpcflag for JSONL-over-stdio headless/agent integrationresolveBreakpointPath— SDK utility that normalizes file paths for breakpoints (server paths, local paths, cartridge-name-prefixed paths)Test plan
test-rpc-debug.shend-to-end via JSONL stdin/stdoutpnpm run test:agent)pnpm -w run docs:build)