Class: MCP::Tool::Schema
- Inherits:
-
Object
- Object
- MCP::Tool::Schema
- Defined in:
- lib/mcp/tool/schema.rb
Direct Known Subclasses
Defined Under Namespace
Classes: ValidationCache
Constant Summary collapse
- VALIDATION_CACHE =
ValidationCache.new
- 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.
"https://json-schema.org/draft/2020-12/schema"- DRAFT4_META_SCHEMA_URI =
"http://json-schema.org/draft-04/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.
46 47 48 49 50 |
# File 'lib/mcp/tool/schema.rb', line 46 def initialize(schema = {}) @schema = JSON.parse(JSON.dump(schema), symbolize_names: true) @schema[:type] ||= "object" validate_schema! end |
Instance Method Details
#==(other) ⇒ Object
52 53 54 |
# File 'lib/mcp/tool/schema.rb', line 52 def ==(other) other.is_a?(self.class) && @schema == other.instance_variable_get(:@schema) end |
#to_h ⇒ Object
56 57 58 59 60 |
# File 'lib/mcp/tool/schema.rb', line 56 def to_h return @schema if @schema.key?(:"$schema") { "$schema": JSON_SCHEMA_2020_12_URI }.merge(@schema) end |