MCP App Tool UI Rendering#
Tool UI rendering in assistant-ui resolves which React component to display for a tool-call message part. The lookup cascade is: named tool UI ā MCP App renderer ā inline fallback ā platform default. "MCP App" refers to tool calls whose mcp.app.resourceUri starts with the ui:// scheme ā these carry embedded UI delivered by an MCP server and need a separate renderer path.
Key Concepts#
| Concept | What it is |
|---|---|
| Named tool UI | A per-tool-name renderer stored in ToolsState.toolUIs, keyed by toolName. |
| MCP App renderer | A single fallback renderer (ToolsState.mcpApp) used for any tool-call part whose mcp.app.resourceUri is a ui:// URI. |
| Inline Fallback | A Fallback component supplied directly as a prop to the message renderer. |
isMcpAppUri | Helper that returns true when uri?.startsWith("ui://") . |
Tool UI Resolution Logic#
The authoritative resolution function is resolveToolRender in packages/core/src/react/primitives/message/MessageParts.tsx:
- Named match ā check
toolsState.toolUIs[part.toolName]?.[0]?.render. - MCP App match ā if no named match and
isMcpAppUri(part.mcp?.app?.resourceUri)is true, returntoolsState.mcpApp.render. - Return null ā rendering is delegated to the caller.
toolsState.toolUIs[toolName]?.[0]?.render ā named UI (wins)
isMcpAppUri(part.mcp?.app?.resourceUri) ā toolsState.mcpApp.render
null ā fallback / nothing
Render Paths by Package#
@assistant-ui/core ā MessagePrimitiveParts / MessagePartComponent#
MessagePartComponent handles the tool-call branch:
- If
tools.Overrideis provided ā render it directly (bypasses registry). - Resolve
tools.by_name[toolName]ortools.Fallbackas the inline fallbackTool. - Pass both to
ToolUIDisplayā which readstoolsState.toolUIs[toolName]?.[0]?.render ?? Fallbackfrom the store.
Important: ToolUIDisplay in MessagePartComponent reads only toolUIs[toolName]?.[0]?.render ?? Fallback ā it does not call resolveToolRender and therefore does not apply the MCP App fallback. The MCP App path is available through resolveToolRender used inside RegisteredToolUI and the children render function path (MessagePartChildrenInner).
When <MessagePrimitive.Parts> is used with a children render prop, DefaultPartFallback is inserted automatically when children returns null ā it renders <RegisteredToolUI /> (which uses resolveToolRender, including the MCP App check) for tool-call parts.
@assistant-ui/react ā MessagePartsGrouped#
MessagePartsGrouped's ToolUIDisplay follows the same named-only pattern as core: toolUIs[toolName]?.[0]?.render ?? Fallback. The MCP App path is not applied in this render path.
@assistant-ui/react-ink ā MessageContent#
ToolUIDisplay in react-ink reads toolUIs[part.toolName]?.[0]?.render. If found, renders it; if not, tries the inline Fallback prop; then falls back to <ToolFallback> (a terminal renderer that displays collapsible tool call details with Allow/Deny controls for pending approvals). No MCP App resolution.
@assistant-ui/react-native ā MessageContent#
ToolUIDisplay mirrors the react-ink pattern: named UI ā inline Fallback ā null. No ToolFallback terminal renderer; unregistered tools render nothing.
Registering the MCP App Renderer#
MCP App rendering is wired via Tools({ mcpApp: McpAppRenderer(options) }) :
Toolsaccepts an optionalmcpAppresource element.- It evaluates the resource via
useResourcesand stores the output ({ render }) inToolsState.mcpApp. McpAppRendereris aresource(useMcpAppRenderer)that produces a stablerendercomponent pointing to<InlineRenderer>(a sandboxed frame loading theui://resource from the configured host). Component identity is kept stable to avoid remounting frames on re-render .
Public exports:
McpAppRendererā from@assistant-ui/reactMcpAppResourceOutputā from@assistant-ui/core/reactisMcpAppUri,MCP_APP_URI_SCHEMEā from@assistant-ui/core
Data UI Resolution (parallel pattern)#
data-type parts use an analogous two-tier lookup via getDataRenderer:
dataRenderers.renderers[name]?.[0](named)dataRenderers.fallbacks[0](global fallback)- Inline
Fallbackprop (caller-supplied)
Source Files#
| File | Role |
|---|---|
packages/core/src/react/primitives/message/MessageParts.tsx | Platform-agnostic base: resolveToolRender, ToolUIDisplay, RegisteredToolUI, DefaultPartFallback, MessagePrimitiveParts |
packages/core/src/react/types/scopes/tools.ts | ToolsState, McpAppResourceOutput type definitions |
packages/core/src/types/message.ts | McpAppMetadata, isMcpAppUri, MCP_APP_URI_SCHEME |
packages/core/src/react/client/Tools.ts | Tools resource ā registers tool UIs and mcpApp into scope |
packages/react/src/mcp-apps/McpAppRenderer.tsx | McpAppRenderer resource ā produces the ui:// frame renderer |
packages/react/src/primitives/message/MessagePartsGrouped.tsx | Web aggregate render path (Unstable_PartsGrouped) |
packages/react-ink/src/primitives/message/MessageContent.tsx | Ink render path with ToolFallback terminal |
packages/react-native/src/primitives/message/MessageContent.tsx | React Native render path |