Schema validation for MCP content.
Experimental
Helper utilities outside the core Handler/DSL path. Prefer tool
output_schema on ExMCP.Server.DSL for structured tool results.
Field/size/MIME helpers are implemented. validate_schema/2 uses
ExJsonSchema when available.
Summary
Functions
Validates content format and structure.
Validates content size against maximum limits.
Validates MIME types against allowed types.
Validates that required fields are present and non-empty.
Validates content against a JSON Schema using ExJsonSchema.
Types
@type validation_result() :: :ok | {:error, [validation_error()]}
Functions
@spec validate_format(ExMCP.Content.Protocol.content()) :: validation_result()
Validates content format and structure.
@spec validate_max_size(ExMCP.Content.Protocol.content(), pos_integer()) :: validation_result()
Validates content size against maximum limits.
@spec validate_mime_types(ExMCP.Content.Protocol.content(), [String.t()]) :: validation_result()
Validates MIME types against allowed types.
@spec validate_required_fields(ExMCP.Content.Protocol.content()) :: validation_result()
Validates that required fields are present and non-empty.
@spec validate_schema(ExMCP.Content.Protocol.content() | map(), map()) :: validation_result()
Validates content against a JSON Schema using ExJsonSchema.
Content maps are converted to JSON-compatible string-keyed maps (atoms become strings) before validation.