Module: ToolSchema::FastMcpBuilder
- Extended by:
- T::Sig
- Defined in:
- app/lib/tool_schema/fast_mcp_builder.rb
Class Method Summary collapse
- .arguments_block(params_ast) ⇒ Object
- .build_param(ctx, param) ⇒ Object
- .scalar_symbol(type) ⇒ Object
- .scalar_type?(type) ⇒ Boolean
Class Method Details
.arguments_block(params_ast) ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/lib/tool_schema/fast_mcp_builder.rb', line 11 def self.arguments_block(params_ast) proc do params_ast.each do |param| FastMcpBuilder.build_param(self, param) end end end |
.build_param(ctx, param) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/lib/tool_schema/fast_mcp_builder.rb', line 20 def self.build_param(ctx, param) wrapper = param[:required] ? ctx.required(param[:name]) : ctx.optional(param[:name]) node = case param[:type] when :object wrapper.hash do (param[:children] || []).each do |child| FastMcpBuilder.build_param(self, child) end end when :array item = param[:item_type] if item && scalar_type?(item[:type]) wrapper.array(scalar_symbol(item[:type])) elsif item&.dig(:type) == :object wrapper.array(:hash) do (item[:children] || []).each do |child| FastMcpBuilder.build_param(self, child) end end else wrapper.array(:any) end else wrapper.value(scalar_symbol(param[:type])) end node.description(param[:description]) if param[:description] end |
.scalar_symbol(type) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'app/lib/tool_schema/fast_mcp_builder.rb', line 56 def self.scalar_symbol(type) case type when :string then :string when :integer then :integer when :float then :float when :boolean then :bool else :any end end |
.scalar_type?(type) ⇒ Boolean
51 52 53 |
# File 'app/lib/tool_schema/fast_mcp_builder.rb', line 51 def self.scalar_type?(type) %i[string integer float boolean any].include?(type) end |