Widget Rendering Flow
Here’s what happens when ChatGPT renders a widget:- User asks ChatGPT to perform an action (e.g., “Show me flight options to Paris”)
- ChatGPT calls your MCP tool (e.g.,
search_flights) - Your tool returns a result with data and a reference to a UI resource
- ChatGPT fetches the resource (your compiled React component) and renders it in an iframe
- The widget is hydrated with your tool’s
structuredContentand_metaproperties
The window.openai API
Widgets run inside an iframe and have access to a special window.openai global that enables communication with the host:
| API | Description |
|---|---|
toolOutput | Access the initial data passed from your tool |
widgetState | Persist UI state across interactions |
callTool() | Trigger additional tool calls from the UI |
sendFollowUpMessage() | Send messages back into the chat |
setWidgetState() | Update persistent state |
requestModal() | Open a modal window outside the iframe |
uploadFile() | Upload files to host-managed storage |
getFileDownloadUrl() | Get download URLs for uploaded files |
openExternal() | Open external URLs safely |
Skybridge Hook Mapping
Skybridge wraps the rawwindow.openai API with React hooks:
| Raw API | Skybridge Hook | Purpose |
|---|---|---|
window.openai.toolOutput | useToolInfo() | Access initial tool input/output |
window.openai.widgetState and window.openai.setWidgetState | useWidgetState() | Persistent widget state |
window.openai.callTool() | useCallTool() | Make additional tool calls |
window.openai.sendFollowUpMessage() | useSendFollowUpMessage() | Send follow-up messages |
window.openai.openExternal() | useOpenExternal() | Open external URLs |
window.openai.view and window.openai.requestModal() | useRequestModal() | Request modal display |
window.openai.theme | useLayout() | Access ChatGPT theme |
window.openai.locale | useUser() | Access user locale |
window.openai.displayMode and window.openai.requestDisplayMode | useDisplayMode() | Access/change display mode |
window.openai.uploadFile() | useFiles() | Upload and download files |
Apps SDK Exclusive Features
These features are only available in ChatGPT and not supported in MCP Apps:Modal Windows
Open content in a separate modal window outside the iframe:File Operations
Upload and download files with host-managed storage:Testing in ChatGPT
To test your app in ChatGPT:- Go to ChatGPT Settings > Developer Settings
- Enable Developer Mode
- Add your MCP server URL
- Start a new conversation and invoke your tools
Related
- MCP Apps - The open alternative runtime
- Platform Agnosticism - How Skybridge handles both runtimes
- useRequestModal - Modal API reference
- useFiles - File operations API reference
