Class: Ask::MCP::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/ask/mcp/tool.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, description: "", input_schema: {}) ⇒ Tool

Returns a new instance of Tool.



8
9
10
11
12
# File 'lib/ask/mcp/tool.rb', line 8

def initialize(name:, description: "", input_schema: {})
  @name = name
  @description = description
  @input_schema = input_schema
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/ask/mcp/tool.rb', line 6

def description
  @description
end

#input_schemaObject (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

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/ask/mcp/tool.rb', line 6

def name
  @name
end

Class Method Details

.from_h(hash) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/ask/mcp/tool.rb', line 32

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"] || {}
  )
end

Instance Method Details

#to_ask_toolObject



14
15
16
17
18
19
20
21
22
# File 'lib/ask/mcp/tool.rb', line 14

def to_ask_tool
  require "ask/tools/tool"

  Ask::Tools::Tool.new(
    name: @name,
    description: @description,
    parameters: @input_schema
  )
end

#to_hObject



24
25
26
27
28
29
30
# File 'lib/ask/mcp/tool.rb', line 24

def to_h
  {
    name: @name,
    description: @description,
    inputSchema: @input_schema
  }
end