AI Engineer

Generative UI... in Python? — Jeremiah Lowin, Prefect

Published 2026-09-10 · Duration 17:38

Summary

This talk introduces Prefect, a Python DSL designed to solve the challenge of delivering rich, interactive UIs within the MCP (Messaging/Communication Protocol) ecosystem. While MCP apps allow tools to bypass the agent and render full HTML/CSS/JS interfaces, the primary user base (Python engineers in enterprises) needed a way to build these UIs without writing complex frontend code. Prefect achieves this by allowing developers to compose UIs using Python context managers and classes, which are then serialized into a JSON protocol and rendered by a React app. A key optimization is streaming the Python code itself over the wire and executing it in a sandbox, resulting in a 70% reduction in size compared to streaming the JSON representation.

Download summary

Key takeaways

  1. MCP Apps and Agent Bypass

    MCP apps are an extension of the MCP protocol that allows tool results to bypass the agent and be delivered directly to the user as a full UI (HTML, CSS, JavaScript), enabling rich, interactive experiences.

  2. The Prefect Solution 9:03

    Prefect is a Python DSL that allows developers to compose UIs by nesting components using context managers, avoiding the need to write traditional frontend code.

  3. The Core Pipeline 10:37

    The process involves using a Python DSL to build a declarative representation, which is serialized into a JSON protocol. This JSON is then rendered by a React app hosted as the MCP app.

  4. Efficiency Improvement 16:40

    The system was optimized to stream the Python representation of the UI over the wire and execute it in a sandbox, which was found to be approximately 70% smaller and more efficient than streaming the full JSON protocol.

Technical details

  • MCP Protocol Extension 0s

    MCP apps allow tool results to be delivered as a full UI (HTML, CSS, JS), enabling direct user interaction without the agent's context window being the sole intermediary.

  • Python DSL and Composition 543s

    Prefect uses Python context managers to build the UI structure, treating every component as a class that can be instantiated and parameterized. This approach focuses on composing existing, world-class components rather than building a UI from scratch.

  • Client-Side Interactivity 730s

    Reactive variables (RX) allow for creating client-side interactivity and binding data between components without requiring explicit JavaScript code.

  • FastMCP Integration 890s

    In FastMCP, returning a Prefect component from a tool function automatically signals that the result should be an MCP app, triggering the necessary machinery to render the interactive UI for the user.

  • File Upload Improvement 950s

    Prefect enables a secure and efficient file upload mechanism for MCP apps, allowing files to bypass the agent and go directly to the server, solving the 'world's most expensive copy paste operation' problem.

Mentioned resources

  • Prefect (DSL/Framework)
  • FastMCP (Framework)

Channel & topics

Watch on YouTube · Back to latest

This independent, AI-assisted summary is provided for commentary and informational purposes. It may contain errors or omit important context. Please watch the original video for the creator's complete presentation. Video, thumbnail, and related copyrights belong to their respective owners.