Skip to content

Add script debugger MCP tools, CLI REPL, and RPC mode#395

Draft
clavery wants to merge 7 commits intomainfrom
feature/debug-mcp
Draft

Add script debugger MCP tools, CLI REPL, and RPC mode#395
clavery wants to merge 7 commits intomainfrom
feature/debug-mcp

Conversation

@clavery
Copy link
Copy Markdown
Collaborator

@clavery clavery commented May 4, 2026

Summary

  • MCP debug tools — 13 tools added to CARTRIDGES, SCAPI, and STOREFRONTNEXT toolsets for agent-native script debugging (start/end sessions, breakpoints, wait for halt, stack/variables/evaluate, step, capture-at-breakpoint)
  • ServerContext architecture — persistent server-scoped state across MCP tool invocations, enabling stateful debug sessions alongside the existing per-call config reloading
  • b2c debug cli — interactive REPL for terminal-based debugging with --rpc flag for JSONL-over-stdio headless/agent integration
  • resolveBreakpointPath — SDK utility that normalizes file paths for breakpoints (server paths, local paths, cartridge-name-prefixed paths)
  • Docs — CLI debug reference page, MCP diagnostics tools page, b2c-debug agent skill
  • MCP tools sidebar — reorganized by use case (Cartridges, SCAPI, PWA Kit, Storefront Next, Diagnostics)

Test plan

  • MCP tools: start session, set breakpoints, trigger request, wait for stop, get stack/variables, evaluate, continue, end session
  • CLI REPL: interactive breakpoint/step/inspect workflow
  • CLI RPC: test-rpc-debug.sh end-to-end via JSONL stdin/stdout
  • Path normalization: server paths, relative local paths, cartridge-prefixed paths
  • Existing MCP tools unaffected by ServerContext threading
  • All existing tests pass (pnpm run test:agent)
  • Docs build (pnpm -w run docs:build)
  • MCP tools sidebar grouping renders correctly

clavery added 7 commits May 3, 2026 20:32
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant