Class: DebugMcp::Tools::SetBreakpoint

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/debug_mcp/tools/set_breakpoint.rb

Class Method Summary collapse

Class Method Details

.call(file: nil, line: nil, method: nil, exception_class: nil, condition: nil, one_shot: nil, session_id: nil, server_context:) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/debug_mcp/tools/set_breakpoint.rb', line 66

def call(file: nil, line: nil, method: nil, exception_class: nil, condition: nil, one_shot: nil, session_id: nil, server_context:)
  manager = server_context[:session_manager]
  client = manager.client(session_id)
  client.auto_repause!

  if exception_class
    set_catch_breakpoint(client, manager, exception_class)
  elsif method
    set_method_breakpoint(client, manager, method, condition: condition, one_shot: one_shot)
  elsif file && line
    set_line_breakpoint(client, manager, file, line, condition: condition, one_shot: one_shot)
  else
    MCP::Tool::Response.new([{ type: "text",
      text: "Error: Provide 'file' + 'line' for a line breakpoint, " \
            "'method' for a method breakpoint (e.g., 'User#save'), " \
            "or 'exception_class' for an exception breakpoint." }])
  end
rescue DebugMcp::Error => e
  MCP::Tool::Response.new([{ type: "text", text: "Error: #{e.message}" }])
end