mcp-use TypeScript API
    Preparing search index...

    Function ModelContext

    • Annotate a portion of the view UI with a description the model can see.

      Registers content in a hierarchical tree that serializes into an indented markdown list under _uiContext. The store merges that field with useViewState and sends the complete snapshot through ChatGPT widget state or MCP Apps ui/update-model-context. Updates batch per microtask. Failed requests stay dirty and retry after the next mutation.

      An empty content (trimmed) does not register a node and does not orphan children — nested ModelContext nodes re-parent to the nearest registered ancestor (or root).

      On the MCP Apps path, a host without the updateModelContext capability skips pushes and receives a one-time console.warn.

      Parameters

      • props: ModelContextProps

        Component props.

        • content

          Text describing what the user is currently seeing.

        • children

          Optional nested UI; nested ModelContext nodes serialize as indented children of this node when this node has non-empty content.

      Returns Element | null

      <ModelContext content={`Selected: ${item.name}`} />

      <ModelContext content="Dashboard">
      <ModelContext content="Revenue section" />
      </ModelContext>