Anthropic::Schema
Schema DSL for type-safe tool input definitions
Provides a cleaner way to define tool input schemas.
schema: {
"location" => Schema.string("City name"),
"unit" => Schema.enum("celsius", "fahrenheit"),
}
Class methods
array(items : Property, description : String | Nil = nil, min_items : Int32 | Nil = nil, max_items : Int32 | Nil = nil) : Property
Define an array property
Schema.array(Schema.string, description: "List of names")
Schema.array(Schema.integer, min_items: 1, max_items: 10)
Define a boolean property
Schema.boolean("Is active")
Schema.boolean("Enabled", default: true)
Define an enum property with allowed string values
Schema.enum("celsius", "fahrenheit", description: "Temperature unit")
Schema.enum("low", "medium", "high")
integer(description : String | Nil = nil, minimum : Int32 | Nil = nil, maximum : Int32 | Nil = nil, default : Int32 | Nil = nil) : Property
Define an integer property
Schema.integer("Number of items")
Schema.integer("Age", minimum: 0, maximum: 150)
number(description : String | Nil = nil, minimum : Float64 | Nil = nil, maximum : Float64 | Nil = nil, default : Float64 | Nil = nil) : Property
Define a number property (floating point)
Schema.number("Temperature in degrees")
Schema.number("Price", minimum: 0.0, maximum: 1000.0)
object(properties : Hash(String, Property), description : String | Nil = nil, required : Array(String) = [] of String) : Property
Define an object property with nested properties
Schema.object({
"name" => Schema.string("Person's name"),
"age" => Schema.integer("Person's age"),
}, required: ["name"])