Add GenerativeUI provider, bump prefab-ui 0.14.0#3647
Conversation
GenerativeUI is a Provider that adds generative UI capabilities:
- generate_ui tool: accepts Prefab Python code, runs in Pyodide sandbox
- components tool: searchable component library via introspection
- Generative renderer resource with CSP for Pyodide CDN
Usage:
mcp = FastMCP("Server")
mcp.add_provider(GenerativeUI())
GenerativeUI is a Provider that wraps prefab_ui.generative as MCP tools:
- generate_prefab_ui: LLM writes Prefab Python, sandbox executes, UI renders
- search_prefab_components: introspects Prefab component library
- Generative renderer resource with CSP for Pyodide
Bumps prefab-ui to 0.14.0 which removes set_initial_state — all examples
and docs migrated to PrefabApp(state={...}) + Rx("key"). Wire format now
uses $prefab envelope and pf-app-root wrapper.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d46b41324b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if self._setup_done: | ||
| return | ||
| self._setup_done = True |
There was a problem hiding this comment.
Defer setup-complete flag until registration succeeds
Setting _setup_done = True before component registration means any setup-time exception leaves this provider permanently half-initialized. For example, if a caller configures tool_name and components_tool_name to the same value, _add_component raises once, but subsequent list/get calls skip setup and operate on incomplete state (often missing the renderer resource). Mark setup complete only after all registrations succeed (or reset the flag on failure) so retries are safe and deterministic.
Useful? React with 👍 / 👎.
The LLM writes Prefab Python code, the sandbox executes it, the user watches the UI stream in.
GenerativeUIis a Provider that wrapsprefab_ui.generative— all business logic (component introspection, sandbox execution, tool descriptions) lives in Prefab and is versioned with the component library.Two tools registered automatically:
generate_prefab_ui(accepts code, runs sandbox, returns PrefabApp) andsearch_prefab_components(introspects the real Prefab component classes at runtime). The generative renderer resource and CSP (includingconnect_domainsfor Pyodide WASM fetch) are wired up automatically.Also bumps prefab-ui to ≥0.14.0 which removes
set_initial_statein favor ofPrefabApp(state={...}). All examples and docs migrated.