Class: RailsAiBridge::Tools::GetModelDetails
- Defined in:
- lib/rails_ai_bridge/tools/get_model_details.rb
Overview
MCP tool returning ActiveRecord model metadata, optional non-AR app/models listings,
and configurable list detail for all models.
Class Method Summary collapse
-
.call(model: nil, detail: 'summary', format: 'markdown', _server_context: nil) ⇒ MCP::Tool::Response
Returns Markdown for one model or for a full listing.
Methods inherited from BaseTool
cached_context, cached_section, config, rails_app, reset_cache!, text_response
Class Method Details
.call(model: nil, detail: 'summary', format: 'markdown', _server_context: nil) ⇒ MCP::Tool::Response
Returns Markdown for one model or for a full listing.
Reads :models and, when present, :non_ar_models from BaseTool.cached_section.
When model matches a non-AR entry and not an ActiveRecord key, returns a short POJO summary.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rails_ai_bridge/tools/get_model_details.rb', line 45 def self.call(model: nil, detail: 'summary', format: 'markdown', _server_context: nil) models = cached_section(:models) return text_response('Model introspection not available. Add :models to introspectors.') unless models return text_response("Model introspection failed: #{models[:error]}") if models[:error] non_ar = cached_section(:non_ar_models) formatter = ResponseFormatter.new(models, model: model, detail: detail, format: format, non_ar_models: non_ar) return text_response(formatter.) if formatter.model_not_found? return text_response(formatter.) if formatter.model_error? text_response(formatter.format) end |