Noizu.MCP.Schema (Noizu MCP v0.1.3)

Copy Markdown View Source

JSON Schema validation (2020-12, MCP's default dialect) backed by JSV.

Compiled schemas are cached in :persistent_term, keyed by a hash of the raw schema, so repeated tool calls don't pay the build cost.

Summary

Functions

Check that a schema itself is buildable. Returns :ok or {:error, message}.

Build (and cache) a compiled schema; raises on an invalid schema.

Validate data against a raw JSON Schema map (string keys).

Functions

check(schema)

@spec check(map()) :: :ok | {:error, String.t()}

Check that a schema itself is buildable. Returns :ok or {:error, message}.

compiled!(schema)

@spec compiled!(map()) :: JSV.Root.t()

Build (and cache) a compiled schema; raises on an invalid schema.

validate(schema, data)

@spec validate(map(), term()) :: :ok | {:error, String.t()}

Validate data against a raw JSON Schema map (string keys).

Returns :ok or {:error, message} where message is a human/model-readable summary of the violations.