/** * MCP Display Helpers — return prefab UIs as MCP tool results. * * These functions wrap PrefabApp / Component trees into MCP-compatible * tool result content arrays, ready to return from tool handlers. * * @example * ```ts * import { display, display_error } from '@maxhealth.tech/prefab/mcp' * import { autoTable } from '@maxhealth.tech/prefab' * * // In a FastMCP tool handler: * async function listPatients(args, context) { * const patients = await fetchPatients() * return display(autoTable(patients), { title: 'Patient List' }) * } * ``` */ import { type Component } from '../core/component.js'; import { PrefabApp } from '../app.js'; import type { Theme, LayoutHints, ColorMode } from '../app.js'; import type { Action, ActionJSON } from '../actions/types.js'; import type { PipeFn } from '../rx/pipes.js'; import type { McpToolResult } from './types.js'; export interface DisplayOptions { /** Page / app title. */ title?: string; /** Initial reactive state. */ state?: Record; /** Light/dark theme overrides. */ theme?: Theme; /** Reusable component definitions. */ defs?: Record; /** Action(s) to run when the UI mounts. */ onMount?: Action | Action[]; /** Keyboard shortcuts. */ keyBindings?: Record; /** Extra CSS class on root element. */ cssClass?: string; /** Size hints for the host container (iframe, panel, etc.). */ layout?: LayoutHints; /** Inline CSS blocks injected as `