Class: RailsMcpInsight::Tools::AnalyzeController

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/rails_mcp_insight/tools/analyze_controller.rb

Class Method Summary collapse

Class Method Details

.call(controller:, server_context:) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_mcp_insight/tools/analyze_controller.rb', line 21

def self.call(controller:, server_context:)
  config = Configuration.new(project_path: server_context&.dig(:project_path) || Dir.pwd)
  analyzer = Analyzers::ControllerAnalyzer.new(config)
  result = analyzer.analyze(controller)

  if result
    MCP::Tool::Response.new([{ type: "text", text: JSON.pretty_generate(result) }])
  else
    MCP::Tool::Response.new([{ type: "text", text: "Controller '#{controller}' not found." }])
  end
end