Class: DebugMcp::Tools::GetSource

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

Constant Summary collapse

MAX_SOURCE_LINES =
50

Class Method Summary collapse

Class Method Details

.call(target:, session_id: nil, server_context:) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/debug_mcp/tools/get_source.rb', line 37

def call(target:, session_id: nil, server_context:)
  client = server_context[:session_manager].client(session_id)
  client.auto_repause!

  if target.include?("#") || target.include?(".")
    get_method_source(client, target)
  else
    get_class_info(client, target)
  end
rescue DebugMcp::Error => e
  MCP::Tool::Response.new([{ type: "text", text: "Error: #{e.message}" }])
end