Schema guard
Contract-test a JSON payload in one call: validate it against your schema, infer the schema the payload actually implies, diff the two to expose drift, and return a normalized pretty-print.
When to use this pack
An agent consuming a third-party API or another agent's structured output needs to know — before trusting the data — whether the payload still matches the agreed contract, and if not, exactly which fields drifted.
Tools in this pack
- JSON Schema validate $0.002 POST /api/json-validate Validate a JSON document against a JSON Schema (draft-07 subset) and get the list of violations. Supports type, required, properties, items, enum, const, min/max, length, pattern, format, anyOf/allOf/oneOf/not, additionalProperties. Deterministic — check an agent's structured output before you trust it.
- JSON Schema infer $0.002 POST /api/json-schema-infer Infer a draft-07 JSON Schema from sample JSON document(s). Send one sample as json, or several as samples. Heuristic merge rules: required = keys present in every sample, conflicting types become a type union, integer widens to number, and string formats (date-time, date, email, uri, uuid) are detected from values. Complements json-validate.
- JSON diff $0.002 POST /api/json-diff Deep-compare two JSON values. Returns a list of changed/added/removed paths (capped at 1000 differences).
- JSON validate & format $0.001 POST /api/json-format Validate, pretty-print, or minify JSON. Returns parse errors with position when invalid.
Workflow
- Validate the payload against the expected schema with json-validate — the pass/fail verdict with the exact violation list.
- Infer the schema the payload actually implies with json-schema-infer — types, required keys, formats.
- Diff the expected schema against the inferred one with json-diff — the drift report: added fields, changed types, dropped keys.
- Normalize the payload with json-format for a canonical pretty-printed copy to log or store.
Run it in Claude
claude mcp add agent402 -s user -- npx -y agent402-mcp@latest
Then paste this prompt into Claude:
Contract-test this JSON payload using Agent402's schema-guard skill pack: {"id":1,"name":"Ada"} against the expected schema {"type":"object","required":["id"]}. (1) Validate the payload against the schema, (2) infer the schema the payload actually implies, (3) diff expected vs inferred to expose drift, (4) return the normalized pretty-print. Report: valid or not (with violations), and every drifted field with its old vs new type.