Wraps App class
MCP Apps SDK reference
Overview
AppProvider wraps your resource component tree and establishes the connection to the MCP Apps host. All sunpeak hooks read from this context internally, so you never need to pass app as a parameter.
The sunpeak framework adds AppProvider automatically in both sunpeak dev and sunpeak build — you never need to write it yourself. It reads name and version from your project’s package.json for appInfo.
Import
Props
App identification sent to the host during
ui/initialize. In the sunpeak framework, this is sourced from your project’s package.json name and version fields.Capabilities to advertise to the host during initialization. See
McpUiAppCapabilities for the protocol-level type.Options passed to the SDK
App constructor, such as autoResize, strict, or webMcpBridge. sunpeak keeps autoResize: true unless you set it, and reads the options once, when the first connection starts. Pass { webMcpBridge: false } to stop bridging app tools and WebMCP. The entry that sunpeak dev and sunpeak build generate does not pass options, so framework resources can’t set them today. A nested AppProvider reuses the existing App and ignores its options, so this prop only matters in a custom entry that mounts the first AppProvider.Callback invoked after the
App instance is created but before connect(). Use this to register event handlers that must be in place before the initialization handshake.Usage
With event handlers
AppState
The context value provided to child components viauseApp.
Behavior
- HMR persistence — The
Appinstance is stored at module scope and persists across React Fast Refresh. Code changes don’t trigger reconnection. A full page reload establishes a fresh connection. - StrictMode — The provider handles React StrictMode’s double-mount cycle by deduplicating the connection attempt. If a connection is already in flight, the second mount waits for it.
- Single instance — Only one
Appinstance is created per page. MultipleAppProvidermounts (e.g., during StrictMode) share the same underlying connection.