Skip to main content
useToolContext() owns the rendering tool lifecycle. Add focused hooks only for the capabilities a view needs:
  • useCallTool() calls an exported server tool and exposes pending, data, and error state.
  • useViewState() stores an object snapshot and restores it on hosts that support persisted view state.
  • useHostContext() reads locale, platform, display mode, and advertised capabilities.
  • useDisplayMode() requests inline, picture-in-picture, or fullscreen presentation.
  • useSendFollowUp() sends a user-visible follow-up message through a capable host.
  • useOpenExternal() asks the host to open an external URL.
Feature-detect host capabilities before showing optional actions. Keep model-visible state explicit with ModelContext; ordinary React state is private to the mounted iframe.