A Python representation of a UI turns out to run about 70% smaller than the equivalent JSON, a detail that changed how an entire framework streams interfaces over the wire.
@jlowin, founder and CEO of Prefect and creator of FastMCP, walks through that discovery in "Generative UI... in Python?", on
@aiDotEngineer's YouTube. The talk lays out a working pattern for shipping interactive UIs from an MCP server without writing JavaScript.
- MCP apps skip the agent's context window. Normally an MCP tool's result goes back into the agent, but MCP apps let a tool send HTML, CSS, and JavaScript straight to the user instead, so they can search, sort, or click through it directly.
- Prefab, a Python DSL for UI. Jeremiah's team built it so Python engineers can compose interfaces from roughly 130 to 140 pre-built components using nested context managers, without touching React.
- JSON underneath, Python on top. The DSL builds a declarative UI that serializes into a JSON protocol and renders through a React app, which is why adding a pie chart next to a data table is a one-line change.
- Three ways to use it. An interactive tool that returns a Prefab component instead of a dictionary, a full FastMCP app built from app.ui and
app.tools methods, and a generative UI where the agent streams the interface live as it renders.
- The upload problem. Since only the agent can talk to an MCP server, teams ended up having the agent retype uploaded files character by character; a built-in upload component lets a file go straight from the browser to the server instead.
- Python beat JSON on the wire. Once Jeremiah's team saw how much smaller the Python form was, FastMCP switched to streaming Python directly and converting it to JSON server-side, for a real token and latency win.
I'm working through the published talks from AI Engineer World's Fair sharing summaries and takeaways. Follow for more!