OutputSchema

Builds the JSON Schema a tool advertises as McpTool.outputSchema, and checks result maps against it.

override val outputSchema = OutputSchema.obj {
integer("count")
array("events") {
integer("id")
string("title", nullable = true)
string("end", nullable = true)
}
}

Every field is listed in required unless declared optional = true (for keys a tool only sometimes returns). nullable = true allows the key to hold JSON null. Objects stay open (no additionalProperties: false), so adding a result key later is not a breaking change.

Types

Link copied to clipboard

Declares the properties of one object schema.

Functions

Link copied to clipboard

A boolean schema, for ObjectBuilder.array items.

Link copied to clipboard

An integer schema, for ObjectBuilder.array items.

Link copied to clipboard
fun number(): Map<String, Any>

A number schema, for ObjectBuilder.array items.

Link copied to clipboard

An object schema built by block. Use as the top-level McpTool.outputSchema.

Link copied to clipboard
fun string(): Map<String, Any>

A string schema, for ObjectBuilder.array items.

Link copied to clipboard
fun violations(schema: Map<String, Any>, value: Any?): List<String>

Where value breaks schema, as path: problem strings; empty when it conforms. Covers the subset obj emits (type, properties, required, items). Meant for tests that pin a tool's real output to its declared schema.