Class: ZeroMcp::Tool
- Inherits:
-
Object
- Object
- ZeroMcp::Tool
- Defined in:
- lib/zeromcp/tool.rb
Instance Attribute Summary collapse
-
#cached_schema ⇒ Object
readonly
Returns the value of attribute cached_schema.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#execute_block ⇒ Object
readonly
Returns the value of attribute execute_block.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
Instance Method Summary collapse
- #call(args, ctx = {}) ⇒ Object
-
#initialize(name:, description: '', input: {}, permissions: {}, route: nil, &block) ⇒ Tool
constructor
A new instance of Tool.
- #route_method ⇒ Object
- #route_path ⇒ Object
Constructor Details
#initialize(name:, description: '', input: {}, permissions: {}, route: nil, &block) ⇒ Tool
Returns a new instance of Tool.
9 10 11 12 13 14 15 16 17 |
# File 'lib/zeromcp/tool.rb', line 9 def initialize(name:, description: '', input: {}, permissions: {}, route: nil, &block) @name = name @description = description @input = input @permissions = @route = route @execute_block = block @cached_schema = Schema.to_json_schema(@input) end |
Instance Attribute Details
#cached_schema ⇒ Object (readonly)
Returns the value of attribute cached_schema.
7 8 9 |
# File 'lib/zeromcp/tool.rb', line 7 def cached_schema @cached_schema end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/zeromcp/tool.rb', line 7 def description @description end |
#execute_block ⇒ Object (readonly)
Returns the value of attribute execute_block.
7 8 9 |
# File 'lib/zeromcp/tool.rb', line 7 def execute_block @execute_block end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
7 8 9 |
# File 'lib/zeromcp/tool.rb', line 7 def input @input end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/zeromcp/tool.rb', line 7 def name @name end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
7 8 9 |
# File 'lib/zeromcp/tool.rb', line 7 def @permissions end |
#route ⇒ Object (readonly)
Returns the value of attribute route.
7 8 9 |
# File 'lib/zeromcp/tool.rb', line 7 def route @route end |
Instance Method Details
#call(args, ctx = {}) ⇒ Object
19 20 21 |
# File 'lib/zeromcp/tool.rb', line 19 def call(args, ctx = {}) @execute_block.call(args, ctx) end |
#route_method ⇒ Object
23 24 25 26 |
# File 'lib/zeromcp/tool.rb', line 23 def route_method return nil unless @route.is_a?(Hash) (@route[:method] || @route['method'] || 'POST').upcase end |
#route_path ⇒ Object
28 29 30 31 |
# File 'lib/zeromcp/tool.rb', line 28 def route_path return nil unless @route.is_a?(Hash) @route[:path] || @route['path'] || '/' end |