Class: Ask::MCP::Tool
- Inherits:
-
Object
- Object
- Ask::MCP::Tool
- Defined in:
- lib/ask/mcp/tool.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#icons ⇒ Object
readonly
Returns the value of attribute icons.
-
#input_schema ⇒ Object
readonly
Returns the value of attribute input_schema.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, description: "", input_schema: {}, title: nil, icons: []) ⇒ Tool
constructor
A new instance of Tool.
- #to_ask_tool ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name:, description: "", input_schema: {}, title: nil, icons: []) ⇒ Tool
Returns a new instance of Tool.
8 9 10 11 12 13 14 |
# File 'lib/ask/mcp/tool.rb', line 8 def initialize(name:, description: "", input_schema: {}, title: nil, icons: []) @name = name @description = description @input_schema = input_schema @title = title @icons = icons end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/ask/mcp/tool.rb', line 6 def description @description end |
#icons ⇒ Object (readonly)
Returns the value of attribute icons.
6 7 8 |
# File 'lib/ask/mcp/tool.rb', line 6 def icons @icons end |
#input_schema ⇒ Object (readonly)
Returns the value of attribute input_schema.
6 7 8 |
# File 'lib/ask/mcp/tool.rb', line 6 def input_schema @input_schema end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/ask/mcp/tool.rb', line 6 def name @name end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/ask/mcp/tool.rb', line 6 def title @title end |
Class Method Details
.from_h(hash) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/ask/mcp/tool.rb', line 37 def self.from_h(hash) new( name: hash[:name] || hash["name"], description: hash[:description] || hash["description"] || "", input_schema: hash[:inputSchema] || hash["input_schema"] || hash[:input_schema] || hash["inputSchema"] || {}, title: hash[:title] || hash["title"], icons: hash[:icons] || hash["icons"] || [] ) end |
Instance Method Details
#to_ask_tool ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/ask/mcp/tool.rb', line 16 def to_ask_tool require "ask/tools/tool" Ask::Tools::Tool.new( name: @name, description: @description, parameters: @input_schema ) end |
#to_h ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ask/mcp/tool.rb', line 26 def to_h h = { name: @name, description: @description, inputSchema: @input_schema } h[:title] = @title if @title h[:icons] = @icons if @icons.any? h end |