Skip to main content
MCP Apps SDK

Overview

useAutoResize enables automatic size reporting to the host via ResizeObserver. It watches document.body and document.documentElement for size changes and sends ui/notifications/size-changed notifications.
This hook is rarely needed. The useApp hook creates the App with autoResize: true by default, which handles this automatically. Only use useAutoResize if you create the App manually with autoResize: false.

Signature

app
App | null
required
The connected App instance, or null during initialization.

Usage

How It Works

The hook calls app.setupSizeChangedNotifications() when app becomes non-null, and disconnects the ResizeObserver when the component unmounts. The observer monitors both document.documentElement and document.body to catch all size changes.