GenerativeUI lets the LLM write Prefab Python code at runtime and render it as a streaming interactive UI. Instead of calling pre-built tools with fixed interfaces, the model creates tailored visualizations for whatever data it’s working with.
| Component | Type | Purpose |
|---|---|---|
generate_prefab_ui | Tool | Accepts Python code, executes in Pyodide sandbox, renders result |
search_prefab_components | Tool | Lets the LLM discover available Prefab components |
| Generative renderer | Resource | ui:// resource with browser-side Pyodide for streaming |
ontoolinputpartial, so the user watches the UI build up in real time.
Configuration
What the LLM Sees
The tool description includes code examples that teach the LLM the Prefab patterns. The LLM callsgenerate_prefab_ui with a code argument containing Prefab Python, and optionally a data argument to pass in real data from the conversation:
search_prefab_components("Chart") returns matching components with import paths.
Requirements
Requiresfastmcp[apps] (installs prefab-ui). The Pyodide sandbox for server-side validation requires Deno, which installs automatically on first use. The streaming renderer loads Pyodide from CDN in the browser — CSP is configured automatically.
The sandbox includes the Python standard library and Prefab. External packages (NumPy, pandas, etc.) are not available.

