Overview
TheuseHostContext hook subscribes to the full host context object, which contains theme, display mode, locale, safe area insets, container dimensions, and more. It updates reactively whenever the host changes any value.
In addition to providing reactive state, useHostContext automatically applies host-provided styles and fonts to the iframe document. This includes CSS style variables, document theme (light/dark), and @font-face rules for host-provided fonts — all applied on initial context and updated whenever the host context changes.
Wraps onhostcontextchanged
MCP Apps SDK reference
useTheme, useDisplayMode, useLocale, useTimeZone, useUserAgent, usePlatform, useDeviceCapabilities, useSafeArea, useViewport, useStyles, and useToolInfo.
Import
Signature
Returns
Returns the fullMcpUiHostContext object, or null before the first update.