Class: MCP::Tool::Schema

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

Direct Known Subclasses

InputSchema, OutputSchema

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema = {}) ⇒ Schema

Returns a new instance of Schema.



10
11
12
13
14
# File 'lib/mcp/tool/schema.rb', line 10

def initialize(schema = {})
  @schema = deep_transform_keys(JSON.parse(JSON.dump(schema)), &:to_sym)
  @schema[:type] ||= "object"
  validate_schema!
end

Instance Attribute Details

#schemaObject (readonly)

Returns the value of attribute schema.



8
9
10
# File 'lib/mcp/tool/schema.rb', line 8

def schema
  @schema
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/mcp/tool/schema.rb', line 16

def ==(other)
  other.is_a?(self.class) && schema == other.schema
end

#to_hObject



20
21
22
# File 'lib/mcp/tool/schema.rb', line 20

def to_h
  @schema
end