Class: RailsMcpInsight::Tools::AnalyzeModel

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

Class Method Summary collapse

Class Method Details

.call(model:, server_context:) ⇒ Object



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

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

  if result
    MCP::Tool::Response.new([{ type: "text", text: JSON.pretty_generate(result) }])
  else
    MCP::Tool::Response.new([{ type: "text",
                               text: "Model '#{model}' not found. Check the name and try list_models to see available models." }])
  end
end