Class: MCP::Tool::OutputSchema

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

Defined Under Namespace

Classes: ValidationError

Constant Summary collapse

ROOT_SCHEMA_KEYWORDS =

Root-level keywords whose presence means the user already chose a root schema shape, so no ‘type: “object”` default should be merged in.

[:type, :"$ref", :oneOf, :anyOf, :allOf, :not, :if, :const, :enum].freeze

Constants inherited from Schema

Schema::JSON_SCHEMA_2020_12_URI, Schema::MAX_SCHEMA_DEPTH, Schema::MAX_SUBSCHEMA_COUNT, Schema::REFERENCE_KEYWORDS, Schema::VALIDATION_CACHE

Instance Method Summary collapse

Methods inherited from Schema

#==, #initialize, #to_h

Constructor Details

This class inherits a constructor from MCP::Tool::Schema

Instance Method Details

#validate_result(result) ⇒ Object



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

def validate_result(result)
  errors = fully_validate(result)
  if errors.any?
    raise ValidationError, "Invalid result: #{errors.join(", ")}"
  end
end