Class: RailsAiBridge::Tools::GetControllers

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/rails_ai_bridge/tools/get_controllers.rb

Overview

MCP tool listing controllers with actions, filters, and strong params.

Class Method Summary collapse

Methods inherited from BaseTool

cached_context, cached_section, config, rails_app, reset_cache!, text_response

Class Method Details

.call(controller: nil, detail: 'standard', _server_context: nil) ⇒ MCP::Tool::Response

Returns markdown controller summary or an error message.

Parameters:

  • controller (String, nil) (defaults to: nil)

    when set, return detail for that controller only

  • detail (String) (defaults to: 'standard')

    +summary+, +standard+, or +full+ for listings

  • _server_context (Object, nil) (defaults to: nil)

    reserved for MCP transport metadata (unused)

Returns:

  • (MCP::Tool::Response)

    markdown controller summary or an error message



31
32
33
34
35
36
37
38
39
40
# File 'lib/rails_ai_bridge/tools/get_controllers.rb', line 31

def self.call(controller: nil, detail: 'standard', _server_context: nil)
  data = cached_section(:controllers)
  return text_response('Controller introspection not available. Add :controllers to introspectors.') unless data
  return text_response("Controller introspection failed: #{data[:error]}") if data[:error]

  formatter = ResponseFormatter.new(data[:controllers] || {}, controller: controller, detail: detail)
  return text_response(formatter.controller_not_found_message) if formatter.controller_not_found?

  text_response(formatter.format)
end