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.004 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 (any indentation, 0-8 spaces), or minify JSON, optionally with object keys sorted. canonical: true returns the RFC 8785 (JCS) canonical form - keys sorted, no whitespace, ECMAScript number and string serialization - plus its SHA-256, for hashing and signing. Numbers are read as IEEE-754 doubles and a duplicate key keeps its last value. Returns parse errors with position when invalid.
Bought one at a time, these 4 tools cost $0.004 together; the pack is that sum less a 10% bundle discount, rounded up to the $0.001 settlement floor, which is $0.004.
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.
Arguments
| Name | Required | Description | Example |
|---|---|---|---|
payload | yes | The JSON payload to check (as a JSON string) | {"id":1,"name":"Ada"} |
schema | no | The expected JSON Schema (as a JSON string; defaults to none) | {"type":"object","required":["id"]} |
What one call returns
A JSON object with pack, args, steps, summary; steps holds one entry per tool (json-validate, json-schema-infer, json-diff, json-format), each with its own result or error. Full example on the API page.
Call it directly
Any x402 client pays the 402 and gets the whole workflow back in one response. With the agent402-client SDK (npm i agent402-client, an ES module):
import { Agent402 } from "agent402-client";
// payFetch: an x402-wrapped fetch your wallet signs (@x402/fetch).
// Tools on the free tier need no options: new Agent402() pays them by proof-of-work.
// an existing prepaid credits key also works: new Agent402({ creditsKey })
const client = new Agent402({ fetch: payFetch });
const result = await client.call("skill-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.