MCP server

Resources

The ui://dtpr/datachain/view.html MCP App resource and session-scoped rendering.

Resources

DTPR exposes one MCP resource — an MCP App HTML document produced by the render_datachain tool.

Resource descriptor

{
  "uri": "ui://dtpr/datachain/view.html",
  "name": "DTPR Datachain View",
  "description": "Rendered DTPR datachain HTML (MCP App iframe)",
  "mimeType": "text/html;profile=mcp-app"
}

The text/html;profile=mcp-app mime type is the MCP Apps convention (SEP-1865) for HTML that an MCP client can embed inside an iframe.

Session scoping

The HTML returned by resources/read is the last document render_datachain produced in the same session. Sessions are keyed by the mcp-session-id request header.

render_datachain   (mcp-session-id: S) → stores HTML in slot S
resources/read     (mcp-session-id: S) → reads HTML from slot S

Two concurrent clients that each set a unique mcp-session-id will not see each other's documents. Clients that omit the header share a single fallback slot (__dtpr_default_session__) and may observe cross-talk — set the header to avoid this.

Reading before rendering

resources/read arriving before any render_datachain tool call in the session returns a neutral placeholder:

<!DOCTYPE html>
<html>
  <head><title>DTPR datachain (awaiting tool call)</title>

This keeps the MCP App UI loadable while the agent is still working.

End-to-end example

SID=$(uuidgen)

# 1. Render the datachain.
curl -s https://api.dtpr.io/mcp \
  -H 'content-type: application/json' \
  -H "mcp-session-id: $SID" \
  --data "{
    \"jsonrpc\":\"2.0\",\"id\":1,
    \"method\":\"tools/call\",
    \"params\":{
      \"name\":\"render_datachain\",
      \"arguments\":{
        \"version\":\"ai@2026-04-16-beta\",
        \"datachain\":{
          \"schema_version\":\"ai@2026-04-16-beta\",
          \"elements\":[{\"element_id\":\"purpose.example\"}]
        }
      }
    }
  }"

# 2. Fetch the rendered HTML.
curl -s https://api.dtpr.io/mcp \
  -H 'content-type: application/json' \
  -H "mcp-session-id: $SID" \
  --data '{
    "jsonrpc":"2.0","id":2,
    "method":"resources/read",
    "params":{"uri":"ui://dtpr/datachain/view.html"}
  }'

The second response carries:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "contents": [
      {
        "uri": "ui://dtpr/datachain/view.html",
        "mimeType": "text/html;profile=mcp-app",
        "text": "<!DOCTYPE html>…"
      }
    ]
  }
}

Hand contents[0].text to your iframe's srcdoc.

See also

Copyright © 2026