Module: FastMcp::BasicTypePredicateHandler
- Included in:
- SchemaCompiler
- Defined in:
- lib/mcp/tool.rb
Overview
Module for handling basic type predicates
Instance Method Summary collapse
-
#add_basic_type(predicate_name, property) ⇒ Object
Add basic type to schema.
-
#add_numeric_constraint(predicate_name, args, property) ⇒ Object
Add numeric constraint to schema.
-
#add_string_constraint(predicate_name, args, property) ⇒ Object
Add string constraint to schema.
Instance Method Details
#add_basic_type(predicate_name, property) ⇒ Object
Add basic type to schema
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/mcp/tool.rb', line 428 def add_basic_type(predicate_name, property) case predicate_name when :array? property[:type] = 'array' property[:items] = {} when :bool? property[:type] = 'boolean' when :int?, :decimal?, :float? property[:type] = 'number' when :hash? property[:type] = 'object' when :nil? property[:type] = 'null' when :str? property[:type] = 'string' end end |
#add_numeric_constraint(predicate_name, args, property) ⇒ Object
Add numeric constraint to schema
459 460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/mcp/tool.rb', line 459 def add_numeric_constraint(predicate_name, args, property) case predicate_name when :gt? property[:exclusiveMinimum] = args[0] when :gteq? property[:minimum] = args[0] when :lt? property[:exclusiveMaximum] = args[0] when :lteq? property[:maximum] = args[0] end end |
#add_string_constraint(predicate_name, args, property) ⇒ Object
Add string constraint to schema
447 448 449 450 451 452 453 454 455 456 |
# File 'lib/mcp/tool.rb', line 447 def add_string_constraint(predicate_name, args, property) case predicate_name when :min_size? property[:minLength] = args[0].to_i when :max_size? property[:maxLength] = args[0].to_i when :included_in? property[:enum] = args[0].to_a end end |