Skip to content

Function: buildRenderDataTool()

buildRenderDataTool(config): Tool<{ data: readonly Record<string, unknown>[]; description?: string; title: string; }, { chartId: string; marker: string; }, unknown, unknown, ToolExecutionContext<unknown, unknown, unknown>, "render_data", unknown>

Build the render_data Mastra tool bound to the given plugin config. Auto-wired as a system tool on every agent (see agents.ts); per-agent tools can shadow it by registering a same-named entry.

Thin wrapper over prepareChart for callers that already have a dataset in hand. Mints a chartId synchronously, caches an empty placeholder, and kicks off the chart-planner in the background. Returns the chartId plus its ready-to-copy marker; the host UI resolves that marker through the plugin’s /embed/chart/:id route.

For Genie statement results, prefer the Genie agent’s prepare_chart tool, which accepts a statement_id and resolves the rows lazily.

MastraPluginConfig

Tool<{ data: readonly Record<string, unknown>[]; description?: string; title: string; }, { chartId: string; marker: string; }, unknown, unknown, ToolExecutionContext<unknown, unknown, unknown>, "render_data", unknown>