Taxonomy
Tools

MCP tool: validate_resolved

Validate a ResolvedDatachainInstance against its referenced schema.

validate_resolved

Soft-failure (isError: false) on every validation outcome. ok: true and ok: false are both successful tool calls — the answer is in the envelope.

Summary

MCP sibling to POST /schemas/:version/validate_resolved. Validates a snapshot-pinned ResolvedDatachainInstance end-to-end:

  • Element-id resolution against schema_snapshot.elementssuggested_elements (snapshot wins; collision is a hard error).
  • R14 wire enforcement: non-empty suggested_elements requires authoring_provenance.kind === 'ai_generated'.
  • Existing semantic rules (cardinality, required categories, context refs) operating against the merged element pool.
  • Snapshot consistency vs the live store, when the pinned version is still served (R9).

Input

{
  "version": "ai@2026-04-16-beta",
  "datachain": { /* ResolvedDatachainInstance */ }
}

Output — valid

{
  "structuredContent": {
    "ok": true,
    "data": { "ok": true, "warnings": [] },
    "meta": { "content_hash": "sha256-…", "version": "ai@2026-04-16-beta" }
  }
}

Output — invalid

{
  "structuredContent": {
    "ok": false,
    "errors": [
      {
        "code": "element_id_collision",
        "message": "id 'foo' present in both schema_snapshot.elements and suggested_elements",
        "path": "suggested_elements"
      }
    ]
  }
}

Error codes

CodeMeaning
parse_errorResolved-form Zod parse failed.
element_id_collisionSame id in schema_snapshot.elements and suggested_elements (R15a).
provenance_requiredNon-empty suggested_elements without authoring_provenance.kind === 'ai_generated' (R14).
element_provenance_unknown_elementA key in authoring_provenance.element_provenance does not match any placement element_id.
unknown_element_idPlacement element_id absent from snapshot ∪ suggested (R15 fallthrough miss).
snapshot_driftschema_snapshot differs from canonical; skipped when the pinned version is no longer in the index.
Semantic validator codesShape-valid but semantically wrong (REQUIRED_CATEGORY_MISSING, etc.).

Example

curl -s https://api.dtpr.io/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  --data '{
    "jsonrpc":"2.0","id":1,
    "method":"tools/call",
    "params":{
      "name":"validate_resolved",
      "arguments":{
        "version":"ai@2026-04-16-beta",
        "datachain": {
          "schema_version":"ai@2026-04-16-beta",
          "elements":[{"element_id":"accept_deny"}],
          "schema_snapshot":{ "datachain_type": { /* ... */ }, "categories":[/*...*/], "elements":[/*...*/] },
          "suggested_elements":[]
        }
      }
    }
  }'

See also