MCP server

Envelope

ok / err payload shape, _meta fields, and soft-failure semantics shared across every tool.

Envelope

Every DTPR MCP tool returns the same { ok, data | errors, meta } envelope, embedded in the MCP tool-result shape. REST consumers see the identical body shape without the MCP wrapper.

Success envelope

{
  "ok": true,
  "data": { "...": "..." },
  "meta": {
    "content_hash": "sha256-…",
    "version": "ai@2026-04-16-beta",
    "next_cursor": null
  }
}
FieldMeaning
oktrue for success.
dataTool-specific payload (see each tool page).
meta.content_hashHex content hash of the schema version being read. Stable across reads of the same version.
meta.versionCanonical schema version, e.g. ai@2026-04-16-beta.
meta.next_cursorOpaque pagination cursor for list_elements / list_categories. null on the final page.
meta.warningsOptional array of short strings. Emitted by validate_datachain / render_datachain when a non-blocking issue was found.

Error envelope

{
  "ok": false,
  "errors": [
    {
      "code": "element_not_found",
      "message": "Element 'missing_element' not found in ai@2026-04-16-beta.",
      "path": "elements[0].element_id",
      "fix_hint": "Use list_elements to enumerate available elements."
    }
  ],
  "meta": { "version": "ai@2026-04-16-beta" }
}
FieldMeaning
errors[].codeStable machine-readable code. See Errors.
errors[].messageHuman-readable diagnostic.
errors[].pathOptional JSON path pointing into the caller's payload.
errors[].fix_hintOptional short instruction for a human or agent.

MCP wrapping

Tools return the envelope twice — as typed structuredContent for 2025-06-18-capable clients, and as a JSON string inside content[0].text for older clients:

{
  "structuredContent": { "ok": true, "data": { "...": "..." }, "meta": { "...": "..." } },
  "content": [
    { "type": "text", "text": "{\"ok\":true,\"data\":{...},\"meta\":{...}}" }
  ]
}

Both carry the same payload; read whichever your client supports.

isError and soft-failure

Hard failures (transport, arguments, unknown version, internal error) surface with isError: true in the tool result. The MCP client should treat them like exceptions.

Soft failures — where the call ran successfully but the answer is "no" or "invalid" — set ok: false without setting isError. The client should read the envelope and display the semantic result.

The soft-failure pattern is used by three tools:

ToolSoft-failure case
validate_datachainInstance is well-formed but semantically invalid (missing required categories, wrong element placement, etc.).
render_datachainSame semantic validation as above; rendering aborts rather than returning a broken document.
get_elementsOne or more requested element ids were not found. The response includes successful hits plus null entries for misses.

Soft-failure example (validate_datachain)

{
  "structuredContent": {
    "ok": false,
    "errors": [
      {
        "code": "element_required",
        "message": "Category 'purpose' requires at least one element.",
        "path": "elements",
        "fix_hint": "Add an element with category_id='purpose'."
      }
    ],
    "meta": {
      "content_hash": "sha256-…",
      "version": "ai@2026-04-16-beta",
      "warnings": []
    }
  },
  "content": [{ "type": "text", "text": "..." }]
}

Note the absence of isError. The client learned the datachain is invalid; the call itself succeeded.

See also

Copyright © 2026