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.
4 tools run server-side in one request. You pay once, settle once, and get a single response - no orchestration, no per-step payments, and a partial-success envelope if any step fails. USDC over x402 on any supported chain.
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
All 4 run inside the single $0.050 call above. Each is also callable on its own if you only need one part.
- JSON Schema validate 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 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 POST /api/json-diff Deep-compare two JSON values. Returns a list of changed/added/removed paths (capped at 1000 differences).
- JSON validate & format 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.
Call it directly
Any x402 client pays the 402 and gets the whole workflow back in one response:
npx agent402-client call schema-guard {"payload":"{\"id\":1,\"name\":\"Ada\"}","schema":"{\"type\":\"object\",\"required\":[\"id\"]}"}
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.