Class: GroqRuby::MCP::Tool

Inherits:
Object
  • Object
show all
Extended by:
GroqRuby::Models::ModelFactory
Defined in:
lib/groq_ruby/mcp/tool.rb

Overview

An MCP tool advertised by a server’s ‘tools/list` response. The `input_schema` is a JSON Schema describing the tool’s arguments.

Class Method Summary collapse

Methods included from GroqRuby::Models::ModelFactory

coerce, coercions, from_hash

Class Method Details

.from_hash(hash) ⇒ Object

Override the factory to map MCP’s camelCase ‘inputSchema` field to our snake_case attribute.



12
13
14
15
16
17
18
19
# File 'lib/groq_ruby/mcp/tool.rb', line 12

def self.from_hash(hash)
  return nil if hash.nil?
  new(
    name: hash["name"] || hash[:name],
    description: hash["description"] || hash[:description],
    input_schema: hash["inputSchema"] || hash[:inputSchema] || hash["input_schema"] || hash[:input_schema] || {}
  )
end