# Generative UI... in Python?

Jeremiah Lowin, Prefect | AI Engineer World's Fair 2026 | 17:38

Source: https://www.youtube.com/watch?v=Krzs8GeiWTc
Channel: AI Engineer (https://www.youtube.com/@aiDotEngineer). Summarised by AIE Talks.
Page: https://aietalks.com/talks/generative-ui-in-python
Published: 2026-09-10
Tags: design, mcp

## TL;DR
- MCP apps let a tool send an interactive HTML, CSS, and JavaScript interface directly to the user instead of routing the result through the agent.
- Prefab narrows UI construction to tables, forms, charts, and other components that Python engineers can compose with context managers.
- A serializable UI protocol enables agents to generate or edit interfaces, while streaming the smaller Python representation can reduce transfer size compared with JSON.

## Summary
Jeremiah Lowin explains why MCP apps need a way to deliver interfaces to users without forcing every result through an agent's context window. FastMCP's audience is mostly Python engineers in enterprises, so Prefect avoided pretending that React could simply be rebuilt in Python. Prefab instead provides a constrained component system for tables, forms, charts, and data applications. Python context managers describe the structure, components render through a React application, and reactive variables add client-side behavior without handwritten JavaScript. Lowin says the important part is the JSON representation in the middle, since an agent or a person can generate, receive, or modify it. Prefab also powers its own documentation, where examples can be edited live. The talk ends with MCP tools, full applications, file uploads that bypass the agent, and generative interfaces. In practice, the team found that Python serialized more compactly than JSON, so it now streams Python to a sandbox before conversion.

## Key ideas
### MCP apps let tool results reach the user as interfaces
[00:27](https://www.youtube.com/watch?v=Krzs8GeiWTc&t=27s)
Ordinary MCP requests send a tool result back into the agent's context, after which the agent creates a response for the user. MCP apps change that path. A tool can send HTML, CSS, and JavaScript directly to the user as a full interface. The user can interact with it and send information back to the app's backend. Lowin gives examples such as booking a restaurant table, changing an airplane seat, or interacting with an event schedule. The agent still initiates the experience, but the person uses the interface directly. He also mentions a coming extension where the agent can interact with the app itself, such as playing chess through a visual board.

### Prefab constrains UI work around the tasks FastMCP users need
[03:07](https://www.youtube.com/watch?v=Krzs8GeiWTc&t=187s)
FastMCP's users are mostly Python engineers, often working inside enterprises. Lowin says they generally do not need consumer-facing, fully branded interfaces. Their work involves sharing information and collecting information across an organization. That makes tables, forms, and charts a useful boundary for the problem. Prefab is an open-source UI framework built around those needs. The constraint avoids asking Python developers to recreate an entire front-end ecosystem. It gives them a set of designed components that can be combined into interfaces for MCP apps and small data applications.

### Prefab composes prepared components instead of recreating a front end
[06:03](https://www.youtube.com/watch?v=Krzs8GeiWTc&t=363s)
Prefab's Python DSL uses nested context managers to express the structure of an interface. Each component is a class that can be instantiated and configured with parameters such as CSS classes. Lowin compares the approach with FastMCP's use of decorators: a context manager can build a complete UI from nested parts. Reactive variables add client-side interaction and allow data to be bound between components without moving into handwritten JavaScript. This keeps users inside a Python workflow while limiting what they can build to a set of components designed to work together.

### The JSON representation matters more than the Python syntax
[07:43](https://www.youtube.com/watch?v=Krzs8GeiWTc&t=463s)
Prefab turns its Python DSL into a declarative UI representation, serializes that representation into a JSON protocol, and has a React app render it as the MCP app. Lowin says the JSON in the middle is the real point. Because it is serializable, an agent can generate it, receive it, or modify it after a person creates it. The Python DSL came later as a convenient way to produce the representation. This intermediate format also supports generative UI, since an agent can produce the protocol rather than calling a fixed interface that a developer wrote in advance.

### Prefab documents itself through live, editable examples
[08:48](https://www.youtube.com/watch?v=Krzs8GeiWTc&t=528s)
Prefab's documentation is rendered entirely with Prefab. The data table shown in the documentation is a live component, and the Python code behind it is rendered by the same system. Readers can move an example into a playground, edit the Python code, and see the interface update. Lowin presents this as a strange result of the team's decision to constrain the problem around composition. The documentation therefore demonstrates the same workflow the library is meant to support: compose predefined components, inspect the code, and change the result immediately.

### Returning a component turns an MCP tool into an interactive result
[09:53](https://www.youtube.com/watch?v=Krzs8GeiWTc&t=593s)
A normal FastMCP tool returns a Python value such as a dictionary, which goes to the agent. With Prefab, the tool can return a component such as a data table instead. FastMCP detects that return value and prepares the MCP app machinery, including the HTML, JavaScript, and CSS needed by the client. Lowin shows a team directory with searching, filtering, sorting, and pagination. The code can then be extended by putting a pie chart and the table inside a grid. Reactive variables connect controls and values on the client, so the interface can update without handwritten JavaScript.

### MCP apps avoid the expensive copy-paste path for file uploads
[12:47](https://www.youtube.com/watch?v=Krzs8GeiWTc&t=767s)
Lowin distinguishes an interactive tool from a full FastMCP app. A full app has a backend, with UI functions that return Prefab components and tool functions that the UI can call. File upload is a practical example. Since only the agent can reach an MCP server, a naive upload tool makes the agent receive the file contents and retype them into the server. Lowin calls this the world's most expensive copy paste operation. An MCP app can display an upload interface instead. The user drags a file into it, and the file goes directly to the server without passing through the agent.

### Generative UI can stream Python into a sandbox before rendering
[14:57](https://www.youtube.com/watch?v=Krzs8GeiWTc&t=897s)
Prefab can expose a tool that accepts the serialized UI protocol, allowing an agent to generate an interface while it streams. Lowin demonstrates an agent creating a UI from a supplied skill and rendering the result as it arrives. The original design streamed JSON, but the team found that the Python representation was about 70% smaller than the JSON representation. The current approach streams Python over the wire, executes it in a sandbox, converts it to JSON on the server, and renders the result. Lowin connects the smaller representation to lower token use, cost, and latency, while keeping the same rendered interface.

## Notable quotes
- "MCP apps is an extension of the MCP protocol that was introduced I think in January of this year." (00:46)
- "I can't pretend we're going to ship React and Python. It's not going to work." (04:00)
- "The key to this whole thing is the JSON in the middle." (08:01)
- "What you end up doing is the world's most expensive copy paste operation." (13:49)
- "The Python representation of a UI is about 70% smaller than the JSON representation." (16:04)

## Tools & references mentioned
- MCP apps
- Model Context Protocol
- FastMCP
- Prefect
- Prefab
- React
- Claude
- Goose
- Shadcn

## Who should watch
- You are building FastMCP tools and need users to interact with results instead of reading agent-generated text.
- Your team is comfortable with Python but needs tables, forms, charts, or file uploads inside MCP apps.
- You are exploring agent-generated interfaces and want a serializable UI format that an agent can create or edit.

## Related talks

- [MCP UI: Extending the frontier](https://aietalks.com/talks/mcp-ui-extending-the-frontier) (Liad Yosef & Ido Salomon, MCP Apps, 22:21)
- [Beyond Components: Designing Generative UI for MCP Apps](https://aietalks.com/talks/beyond-components-designing-generative-ui-for-mcp-apps) (Ruben Casas, Postman, 16:58)
- [MCP Apps: Primitives, Discovery, and the Future of Software](https://aietalks.com/talks/mcp-apps-primitives-discovery-and-the-future-of-software) (Pietro Zullo, Manufact, Inc, 28:54)
- [Building Interactive UIs in VS Code with MCP Apps](https://aietalks.com/talks/building-interactive-uis-in-vs-code-with-mcp-apps) (Marlene Mhangami & Liam Hampton, Microsoft and GitHub, 16:06)
- [The Future of MCP](https://aietalks.com/talks/the-future-of-mcp) (David Soria Parra, Anthropic, 18:46)
