Class: MCP::Tool::Schema
- Inherits:
-
Object
- Object
- MCP::Tool::Schema
- Defined in:
- lib/mcp/tool/schema.rb
Direct Known Subclasses
Constant Summary collapse
- JSON_SCHEMA_2020_12_URI =
JSON Schema 2020-12 is the default dialect for MCP schema definitions per MCP 2025-11-25 (SEP-1613). Note: emission only — runtime validation is still performed against the JSON Schema draft-04 metaschema because the ‘json-schema` gem does not yet support 2020-12.
"https://json-schema.org/draft/2020-12/schema"
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(schema = {}) ⇒ Schema
constructor
A new instance of Schema.
- #to_h ⇒ Object
Constructor Details
#initialize(schema = {}) ⇒ Schema
Returns a new instance of Schema.
16 17 18 19 20 |
# File 'lib/mcp/tool/schema.rb', line 16 def initialize(schema = {}) @schema = JSON.parse(JSON.dump(schema), symbolize_names: true) @schema[:type] ||= "object" validate_schema! end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
14 15 16 |
# File 'lib/mcp/tool/schema.rb', line 14 def schema @schema end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 |
# File 'lib/mcp/tool/schema.rb', line 22 def ==(other) other.is_a?(self.class) && schema == other.schema end |
#to_h ⇒ Object
26 27 28 29 30 |
# File 'lib/mcp/tool/schema.rb', line 26 def to_h return @schema if @schema.key?(:"$schema") { "$schema": JSON_SCHEMA_2020_12_URI }.merge(@schema) end |