Skip to main content
MCP Apps SDK

Overview

sendSizeChanged manually notifies the host that the View’s dimensions have changed. The host uses this information to resize the iframe containing the MCP App. In most cases, you do not need to call this method directly. The App class enables auto-resize by default, which automatically detects DOM changes and sends size updates to the host. Use sendSizeChanged only when you need explicit control over sizing — for example, after an animation completes, when rendering canvas-based content, or when auto-resize is disabled.

Signature

Parameters

params
object
required
width
number
The new width in pixels. If omitted, the host retains the current width.
height
number
The new height in pixels. If omitted, the host retains the current height.

Returns

Returns Promise<void>. The method resolves when the size notification has been sent to the host.

Usage

Setting explicit dimensions

Updating only the height

After an animation or transition

With canvas-based content

When autoResize is enabled (the default), calling sendSizeChanged is unnecessary for standard DOM changes. The auto-resize observer handles this automatically. Disable auto-resize only when you need precise manual control over reported dimensions.
For guidance on when the host expects size updates, see Layout and Display.
  • Auto-Resize — How automatic size detection works in the App class.
  • Layout and Display — How host dimensions, auto-resize, display modes, and safe areas fit together.
  • useAutoResize — React hook for auto-resize behavior.
  • Requests — Overview of all View-to-host request methods.