Generative UI... in Python? — Jeremiah Lowin, Prefect
Prefab lets Python teams compose constrained MCP app interfaces from components, then render them through a JSON protocol and React client without hand-writing frontend code.
Prefab provides roughly **130–140 components** for composing tables, forms, charts, and reactive interfaces in Python. The Python DSL serializes to an intermediate JSON UI protocol, which a React application renders as an MCP app.
For internal agent tools, define a narrow component vocabulary instead of asking models to invent arbitrary frontend code. The serializable representation supports human-authored, agent-modified, or fully generated UI, while FastMCP can provide the backend tools used by the interface.
Prefab provides roughly **130–140 components** for composing tables, forms, charts, and reactive interfaces in Python. The Python DSL serializes to an intermediate JSON UI protocol, which a React application renders as an MCP app. For internal agent tools, define a narrow component vocabulary instead of asking models to invent arbitrary frontend code. The serializable representation supports human-authored, agent-modified, or fully generated UI, while FastMCP can provide the backend tools used by the interface. The team found Python representations about **70% smaller than JSON** and now streams Python into a sandbox before conversion. That improves compactness but adds an execution boundary; the talk gives no security evaluation, latency measurements, or evidence that the approach suits consumer-grade custom interfaces.
Prefab makes constrained generative UI concrete: a compact Python DSL can express a fixed React component vocabulary through MCP instead of generating arbitrary frontend code. It extends the broader MCP Apps pattern with an authoring and serialization approach, but the sandboxed Python execution boundary introduces an unassessed risk, and the evidence does not establish latency, security, or suitability for consumer interfaces.