Class: Archsight::MCP::AnalyzeResourceTool

Inherits:
FastMcp::Tool
  • Object
show all
Defined in:
lib/archsight/mcp/analyze_resource_tool.rb

Instance Method Summary collapse

Instance Method Details

#call(kind:, name:, depth: 0, impact: false, group_by: "kind") ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/archsight/mcp/analyze_resource_tool.rb', line 57

def call(kind:, name:, depth: 0, impact: false, group_by: "kind")
  db = Archsight::MCP.db

  klass = Archsight::Resources[kind]
  return error_response("Unknown resource kind: #{kind}") unless klass

  instance = db.instance_by_kind(kind, name)
  return error_response("Resource not found: #{kind}/#{name}") unless instance

  depth = [[depth.to_i, 0].max, 10].min # Clamp to 0-10

  if impact
    build_impact_analysis(db, instance, kind, name, depth, group_by)
  else
    build_resource_analysis(db, instance, kind, name, depth)
  end
rescue StandardError => e
  error_response(e.message, e.class.name, e.backtrace&.first(10))
end