Skip to main content
MCP Apps SDK

Overview

getHostContext() returns the current host environment context. This includes the theme, styles, locale, time zone, display mode, container dimensions, device capabilities, platform, and safe area insets. The context is first populated during the initialization handshake and automatically updated when the host sends onhostcontextchanged notifications. Returns undefined before connect() completes.

Signature

Returns

return
McpUiHostContext | undefined
The current host context, or undefined if the app has not connected yet. See McpUiHostContext for the full type definition.

Usage

Read the current theme

Check display mode

Use locale for formatting

Adapt to container dimensions

Check device capabilities

Apply safe area insets

Context Fields

Reactivity

getHostContext() always returns the latest context. When the host sends a context change notification, the App class merges the partial update into its stored context. To react to changes: