Skip to main content
Show the chart from an askOmni answer in your own chat. Your backend gets the chart as an interactive page, and your app shows it in a frame. The page has hover tooltips, a chart-type picker, and a table view.

Requirements

To follow the steps on this page, you’ll need:
  • A finished setup, so your backend can mint an MCP token for the user
  • @omni-co/embed version 1.3.0 or later installed in your frontend
  • The jobId from a completed askOmni result

Show a chart

1

Get the chart page on your server

Get the page with the user’s MCP token or with an organization API key, then send it to the browser.
Call the getJobChartPage tool with the user’s MCP token and format: "html". The token reads only that user’s jobs.
Your server
The result’s structuredContent has the HTTP status of the request and the page in body. Pass body to mountOmniFrame as html in the next step. If the call fails, error gives the reason, so show a fallback.The tool refuses a page over 200,000 characters. If it refuses, ask the question again with fewer rows, then get the chart with the new job ID.Call this tool from your own code. If your LLM calls it, the full page goes into the LLM’s context.
2

Show the page in your app

Call mountOmniFrame from @omni-co/embed/browser.
Your page
mountOmniFrame does the following:
  • Frames the page in an iframe sandboxed to allow-scripts only. Don’t add allow-same-origin, because it gives the page your page’s origin.
  • Sizes the frame from the page’s size event.
  • Calls onError and removes the frame when the page sends an error event (page_error), or doesn’t report its size within 15 seconds (start_timeout). A start_timeout usually means your Content Security Policy blocked the page’s script.
  • Removes the frame when you call destroy().
mountOmniFrame also frames a signed embed URL, with { url: signedEmbedUrl }, and sizes embedded dashboards and apps to their content.

Content security policy

The page runs under your page’s Content Security Policy. Allow these:
  • script-src and style-src: Omni’s asset origin, which is the origin of the page’s <script type="module">
  • worker-src: blob:
  • img-src: data:

Next steps