Class: RailsMcpServer::Analyzers::LoadGuide

Inherits:
BaseAnalyzer show all
Defined in:
lib/rails-mcp-server/analyzers/load_guide.rb

Constant Summary collapse

GUIDE_LIBRARIES =
%w[rails turbo stimulus kamal custom].freeze

Instance Method Summary collapse

Instance Method Details

#call(library:, guide: nil) ⇒ Object

Parameters:

library: The guide source - 'rails', 'turbo', 'stimulus', 'kamal', or 'custom'
guide: (optional) Specific guide name to load. If omitted, lists all available guides.

Examples:

execute_tool("load_guide", { library: "rails" })                          # List all Rails guides
execute_tool("load_guide", { library: "rails", guide: "active_record" })  # Load ActiveRecord guide
execute_tool("load_guide", { library: "custom", guide: "tailwind" })      # Load custom Tailwind guide


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails-mcp-server/analyzers/load_guide.rb', line 14

def call(library:, guide: nil)
  unless GUIDE_LIBRARIES.include?(library.to_s.downcase)
    return "Unknown guide library '#{library}'. Available: #{GUIDE_LIBRARIES.join(", ")}"
  end

  guides_path = get_guides_path(library.to_s.downcase)

  unless guides_path && File.directory?(guides_path)
    return "Guides for '#{library}' not found. Run: rails-mcp-server-download-resources #{library}"
  end

  if guide
    load_specific_guide(guides_path, guide)
  else
    list_available_guides(library, guides_path)
  end
end