OzMcp.Structs.EnumSchema (OzMcp v0.9.0)

Copy Markdown View Source

Helper module used to build a single-select enum field of an elicitation form (UntitledSingleSelectEnumSchema or TitledSingleSelectEnumSchema).

(MCP protocol: 2025-11-25)

The options are strings, {value, title} tuples, or maps with const and title (see OzMcp.Structs.EnumOptions). Without titles the schema uses enum; with at least one title it uses oneOf.

Short example:

%EnumSchema{}
  |> EnumSchema.options(["low", "high"])
  |> EnumSchema.default("low")
  |> EnumSchema.build()

Result:

%{type: "string", enum: ["low", "high"], default: "low"}

With titles:

%EnumSchema{}
  |> EnumSchema.options([{"#ff0000", "Red"}, {"#00ff00", "Green"}])
  |> EnumSchema.build()

Result:

%{
  type: "string",
  oneOf: [%{const: "#ff0000", title: "Red"}, %{const: "#00ff00", title: "Green"}]
}

Specification: EnumSchema

Fields

FieldSetterTypeRequired
titletitle/2stringno
descriptiondescription/2stringno
optionsoptions/2list(OzMcp.Structs.EnumOptions.option())no
defaultdefault/2stringno

Summary

Types

t()

@type t() :: %OzMcp.Structs.EnumSchema{
  default: String.t() | nil,
  description: String.t() | nil,
  options: [OzMcp.Structs.EnumOptions.option()],
  title: String.t() | nil
}

Functions

build(struct)

@spec build(t()) :: map()

default(struct, value)

@spec default(t(), String.t() | nil) :: t()

description(struct, value)

@spec description(t(), String.t() | nil) :: t()

options(struct, value)

@spec options(t(), [OzMcp.Structs.EnumOptions.option()]) :: t()

title(struct, value)

@spec title(t(), String.t() | nil) :: t()