Skip to main content
Model context is the information available to the model after a tool returns a widget and while the user interacts with that widget. Use it deliberately: send the model concise text, send the widget structured data, and expose UI state only when it helps the next model turn.

Tool results have separate audiences

An MCP tool result can carry model-visible text and widget-only data at the same time. In mcp-use, widget({ props, output, metadata }) maps these fields for you:
The model can read the output text. The widget reads props and metadata through useWidget(), so it can show details like when the result was generated without adding that detail to the model context.

Keep model text short

Use output to tell the model what happened, not to duplicate the full widget payload.
This keeps large lists, tables, and visualization data out of the model context while still rendering them for the user.

Use props for rendering data

Use props for data the widget needs to render.
props is partial while isPending is true. Check isPending before reading required fields.

Use state for user choices

Use setState for user choices that should survive widget re-renders and be available to future model turns.
State should describe user-visible choices such as selected rows, filters, tabs, favorites, or form progress. Store durable business data in your backend instead.

Use ModelContext for what is visible

Use <ModelContext> when the model should know what part of the widget the user is currently seeing.
<ModelContext> is lifecycle-aware. When the component unmounts, that context is removed. Use modelContext.set() for imperative events that do not map cleanly to JSX:

Choose the right channel

Next steps