<McpUseProvider /> is a universal provider component that works with both MCP Apps and ChatGPT Apps SDK protocols. It automatically includes StrictMode, ThemeProvider, BrowserRouter, optional WidgetControls, and ErrorBoundary, providing a consistent setup regardless of which protocol your widget is using.
Protocol-Agnostic: This component works identically whether your widget is
running in MCP Apps clients or ChatGPT. No conditional logic needed!
Import
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | required | The widget content to wrap |
debugger | boolean | false | Enable debug button in WidgetControls component |
viewControls | boolean | "pip" | "fullscreen" | false | Enable view controls (fullscreen/pip). true shows both, "pip" shows only pip, "fullscreen" shows only fullscreen |
autoSize | boolean | false | Automatically notify OpenAI about container height changes using ResizeObserver |
What’s Included
TheMcpUseProvider automatically wraps your widget with:
- StrictMode (outermost) - React’s development mode checks
- ThemeProvider - Protocol-aware theme management (syncs with both MCP Apps and ChatGPT)
- BrowserRouter - React Router with automatic basename calculation
- WidgetControls (conditional) - Debug and view controls if enabled (works with both protocols)
- ErrorBoundary (innermost) - Error handling for graceful failures
- Auto-sizing container (conditional) - ResizeObserver wrapper if
autoSize={true}(adapts to protocol)
Basic Usage
With Debug Controls
Enable the debug button to inspect widget state, props, and test tool calls:With View Controls
Enable fullscreen and picture-in-picture controls:With Auto-sizing
Enable automatic height notifications for dynamic content:Complete Example
Related Components
WidgetControls- Debug and view controlsThemeProvider- Theme managementErrorBoundary- Error handlinguseWidget- Widget hook for accessing props and actions