Overview
TheuseViewport hook returns the container dimensions provided by the host. This is useful for creating responsive layouts based on the actual available space.
Wraps onhostcontextchanged
MCP Apps SDK reference
Import
Signature
Returns
Container dimension constraints set by the host, or For each axis, the host provides either a fixed value (
null if the host does not report any.The host sends either a fixed size or a maximum constraint for each axis:height/width) or a maximum (maxHeight/maxWidth), never both.Usage
McpUiHostContext.containerDimensions. The inspector exposes Max Height and Max Width inputs under Container Dimensions so you can test how your resource responds to host-enforced size constraints.