GenerativeUI provider registers everything:
generate_prefab_ui— a tool that accepts Python code, executes it in a Pyodide sandbox, and renders the result as a Prefab appsearch_prefab_components— a tool that lets the LLM search the Prefab component library to discover what’s available- The generative renderer — a
ui://resource with browser-side Pyodide for streaming progressive rendering
How It Works
When the LLM decides to callgenerate_prefab_ui, it writes Prefab Python code into the code argument. The MCP Apps protocol creates the renderer iframe in parallel with the tool call, so the app is already running when partial arguments start flowing.
As the LLM generates each token:
- The host forwards partial arguments to the app via
ontoolinputpartial - The renderer extracts the growing
codestring - Browser-side Pyodide executes whatever compiles successfully
- The user sees components appear as they’re written
What the LLM Writes
The tool description includes code examples that teach the LLM the Prefab patterns. A typical generation looks like:The Component Search Tool
Before writing code, the LLM can callsearch_prefab_components to discover what’s available:
detail=True returns full field descriptions and docstrings. The search tool introspects the actual Prefab classes at runtime, so it’s always up to date with the installed version.
Passing Data
Thegenerate_prefab_ui tool accepts a data parameter. Values passed here become global variables in the sandbox:
Configuration
GenerativeUI accepts options for customizing tool names:
Requirements
Generative UI requiresfastmcp[apps] which installs prefab-ui. The Pyodide sandbox (for server-side validation) requires Deno — it installs automatically on first use.
The streaming renderer loads Pyodide from CDN in the browser. The CSP is configured automatically by the provider — no manual setup needed.
Sandbox Limitations
The Pyodide sandbox includes the Python standard library and Prefab. External packages (NumPy, pandas, requests, etc.) are not available — the LLM’s code must work with only built-in Python and Prefab components. If the LLM tries to import an unavailable package, the sandbox will raise anImportError.
Next Steps
- GenerativeUI Provider Reference — Configuration options and quick setup
- Prefab UI — The component library and state system the LLM writes code against
- Prefab Component Reference — Full component library documentation
- Development — Preview generative UI tools locally with
fastmcp dev apps

