Interactive Interfaces Inside the Conversation
A tool result does not have to stop at text: a server can point at a small HTML interface and let the host render it, sandboxed, right where the conversation is already happening. Explain what an interactive interface adds beyond a tool's ordinary text and structured content, and recognize the use cases where reaching for one pays off. Negotiate the io.modelcontextprotocol/ui extension per request and trace a ui:// resource from a tool's meta.ui.resourceUri through an ordinary resources/read call. Read a UI resource's meta.ui.csp domain lists and meta.ui.permissions flags, and construct the Content Security Policy a host must enforce, including its restrictive default. Enforce a tool's visibility so the agent's tool list and an app's own tools/call requests only ever see what each side is allowed to see. Describe the sandboxed iframe security model, the app-to-host bridge, and why an app-initiated tool call still crosses a consent boundary. Design a fallback so a UI-capable tool keeps working for a host that never declares the extension. A dashboard tool that answers "show me sales by region" can return a paragraph of numbers, or it can return a small table wrapped in structuredContent. Neither one lets a user click a region to drill in, hover a bar for the exact figure, or flip between metrics without asking the model to run the tool…
Interactive Interfaces Inside the Conversation: A tool result does not have to stop at text: a server can point at a small HTML interface and let the host…
This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.
Browse the complete course catalog or open this lesson on GitHub.