barrel_mcp_schema (barrel_mcp v2.0.2)
View SourceMinimal JSON Schema validator for MCP tool inputs.
Implements the subset of JSON Schema that real MCP tools use, in pure Erlang with no extra dependencies. Covers:
type:object,array,string,number,integer,boolean,null, or a list of those for unions.properties+requiredfor objects.additionalProperties: falserejection.itemsfor arrays (single schema applied to every item).enumfor string/number/integer/boolean.oneOf/anyOf/allOf(allOf = each must validate).minimum/maximum/exclusiveMinimum/exclusiveMaximumfor numbers and integers.minLength/maxLength/patternfor strings.minItems/maxItems/uniqueItemsfor arrays.
Returns ok or {error, [Error]} where each error is a tuple {Path, Reason} (Path is a list of keys / indices from the root, Reason an atom or {atom, Detail}).
Anything outside the supported subset is silently accepted; this is a permissive validator by design — its job is to catch obvious bugs before sending an LLM-generated arg map to a remote tool, not to be a JSON Schema reference implementation.
Summary
Functions
Validate Value against Schema. Returns ok or {error, [Error]}.