Class: ExplainBaseTool

Inherits:
FastMcp::Tool
  • Object
show all
Defined in:
lib/rails-pg-extras-mcp.rb

Direct Known Subclasses

ExplainAnalyzeTool, ExplainTool

Instance Method Summary collapse

Instance Method Details

#call(sql_query: nil) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rails-pg-extras-mcp.rb', line 69

def call(sql_query: nil)
  connection = RailsPgExtras.connection


  connection.execute("BEGIN;")
  begin
    result = connection.execute("#{sql_query}")
    connection.execute("ROLLBACK;")
    result.to_a
  rescue => e
    connection.execute("ROLLBACK;") rescue nil
    raise e
  end
end