Class: RailsActiveMcp::Sdk::Tools::ModelInfoTool
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- RailsActiveMcp::Sdk::Tools::ModelInfoTool
- Defined in:
- lib/rails_active_mcp/sdk/tools/model_info_tool.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(model: nil, **options) ⇒ ModelInfoTool
constructor
rubocop:disable Lint/MissingSuper.
Constructor Details
#initialize(model: nil, **options) ⇒ ModelInfoTool
rubocop:disable Lint/MissingSuper
49 50 51 52 53 54 55 |
# File 'lib/rails_active_mcp/sdk/tools/model_info_tool.rb', line 49 def initialize(model: nil, **) # rubocop:disable Lint/MissingSuper @model = model @include_schema = .fetch(:include_schema, true) @include_associations = .fetch(:include_associations, true) @include_validations = .fetch(:include_validations, true) @include_enums = .fetch(:include_enums, true) end |
Class Method Details
.call(model:, server_context:) ⇒ Object
45 46 47 |
# File 'lib/rails_active_mcp/sdk/tools/model_info_tool.rb', line 45 def self.call(model:, server_context:, **) new(model:, **).call end |
Instance Method Details
#call ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rails_active_mcp/sdk/tools/model_info_tool.rb', line 57 def call config = RailsActiveMcp.config executor = RailsActiveMcp::ConsoleExecutor.new(config) @result = executor.get_model_info(@model) return error_response unless @result[:success] @output = [] @output << "Model: #{@result[:model_name]}" @output << "Table: #{@result[:table_name]}" @output << "Primary Key: #{@result[:primary_key]}" append_schema if @include_schema append_associations if @include_associations append_validations if @include_validations append_enums if @include_enums MCP::Tool::Response.new([ { type: 'text', text: @output.join("\n") } ]) end |