Skip to content

Debugging

stud0709 edited this page Oct 21, 2026 · 7 revisions

Debugging Tools & Workflows

Use the native SAP ADT debugger tools for Execution-Guard-authorized scratchpad routines and controlled HTTP requests as the connected SAP user. The runtime binds the trigger, external breakpoints, and listener to that connection's private debugger project. Include the initialized workspace's absolute workspace_dir and the selected system_alias in every call.

Available MCP Tools

Tool Name Description
sap_debug_trace One-shot debug trace with an Execution-Guard-authorized scratchpad or controlled HTTP trigger. Captures stack and variables, optionally steps, and cleans up owned debugger resources.
sap_debug_breakpoint Sets, lists, or clears this connection's owned project breakpoints.
sap_debug_attach Attaches to an Execution-Guard-authorized scratchpad or controlled HTTP trigger in this connection's debugger project. Supply scratchpad_params or trigger_uri.
sap_debug_context Retrieves current call stack, local variables, and system fields for an active debug session.
sap_debug_step Steps or continues an active session. Successful terminal actions retire the session and return status: "session_closed".
sap_debug_evaluate Evaluates ABAP expressions, variables, or internal tables in an active debug session.
sap_debug_cleanup Cleans up selected owned debugger sessions and external breakpoints; complete-scope cleanup also retires the owned listener.

Supported triggers and prerequisites

Fetch fresh active source with sap_fetch(for_editing: false) before choosing a breakpoint. For scratchpad routines, request aspect: "implementations" on ZCL_SAP_DEV_RPC_EXT and use an executable line from the returned local implementations source.

Select exactly one trigger form:

  • scratchpad_params invokes the activated EXECUTE_SCRATCHPAD routine through the same Execution Guard as sap_execute_ext_method. The runtime resolves the connection's configured service path. Bundled actions are HELLO_WORLD and CALC, using exact uppercase names.
  • For another authorized HTTP reproduction, supply trigger_request to sap_debug_trace, or trigger_uri and optional HTTP fields to sap_debug_attach. The reproduced operation retains its API and object guard requirements; authorize any business-data effects as part of that reproduction.

Omit user or supply the connected SAP username. A different user returns DEBUGGER_PROJECT_USER_UNSUPPORTED. A missing trigger returns DEBUGGER_CONTROLLED_TRIGGER_REQUIRED. Direct RPC URLs return FORBIDDEN_RPC; use the guarded scratchpad trigger for those routines.

Confirm the connected tool schema exposes scratchpad_params before using that form. A missing parameter calls for a complete skill/runtime update and the matching bundled ABAP reference upgrade through Upgrade. Resolve DEBUGGER_PROJECT_LISTENER_UNSUPPORTED against the selected backend before retrying. Preserve other developers' listeners and debugging settings.

Track A: One-Shot Request Trace (sap_debug_trace)

Supply one breakpoint target (line, statement, exception, or message), one trigger, and optional watch variables. This example traces the guarded scratchpad; replace the URI and line with the executable location from the fresh implementations fetch:

{
  "line": {
    "uri": "/sap/bc/adt/oo/classes/zcl_sap_dev_rpc_ext/includes/implementations",
    "line": 42
  },
  "scratchpad_params": {"action": "HELLO_WORLD", "name": "World"},
  "watch_variables": ["SY-SUBRC"],
  "auto_step_count": 2
}

Inspect structured status and cleanup_applied after the call. Captured variables establish the observed execution state; cleanup needs its own confirmed result. For CALC, supply optional amount and rate; omitted or zero inputs use 100 and 19, and total is their product.

Track B: Interactive Stepping

  1. Set a breakpoint with sap_debug_breakpoint(action: "set"), using one fresh-source line, statement, exception, or message target.
  2. Call sap_debug_attach with scratchpad_params or an authorized controlled HTTP trigger_uri and a bounded timeout_seconds. Retain the returned session_id.
  3. Inspect with sap_debug_context and sap_debug_evaluate. Step with stepInto, stepOver, stepReturn, or stepContinue. Successful detachDebugger and terminateDebuggee actions return status: "session_closed" after retiring the selected session.
  4. Run sap_debug_cleanup for the intended owned resources and inspect its confirmed outcomes.

Owned inventory and recovery

sap_debug_breakpoint(action: "list") returns the connection's owned inventory. provenance: "sap_dev_owner" and completeness: "owner_only" identify that scope. An empty owned inventory establishes only the absence of acknowledged resources in that scope.

Cleanup with session_id selects that session; breakpoint_uri selects owned breakpoints at that exact URI. Both selectors combine those targets. Omitting both selects the connection's complete owned scope and retires its listener. Selective cleanup preserves unselected sessions, breakpoints, and the listener. Preserve recovery evidence and obtain developer assistance when confirmation remains unresolved or native cleanup fails.

Track C: Agent-Assisted SAP GUI Debugging (Windows & Java GUI)

For a GUI-, RFC-, or batch-only reproduction, have the developer perform the investigation in their SAP debugger or capture source, dump, and diagnostic evidence for analysis. The MCP debugger accepts the supported scratchpad and controlled HTTP triggers above. GUI/program triggers return DEBUGGER_GUI_PROJECT_BINDING_UNSUPPORTED; attachment requires a supported trigger.

Use Diagnostics for developer-captured traces and disconnected-system evidence, and SAP GUI Automation for guarded GUI navigation and inspection. Preserve the developer's active debugger and existing settings.

Clone this wiki locally