Overview
TheSimulator component provides a local development environment that replicates the MCP App runtime used by hosts like ChatGPT and Claude. It renders your resources inside iframes, matching the production hosting behavior. The simulator supports multiple host shells — switch between ChatGPT and Claude conversation chrome, theming, and reported capabilities from the sidebar or via URL parameters.
Import
ChatGPTSimulator is available as a backwards-compatible alias: import { ChatGPTSimulator } from 'sunpeak'.Basic Usage
For projects using the sunpeak framework, simulations are auto-discovered. Just run:Props
Object mapping simulation names to their definitions. See
Simulation API Reference for details.
Name of the app displayed in the simulator UI.
Optional icon (emoji) displayed in the simulator UI.
Optional children to render when no simulations are selected.
URL Parameters
The Simulator supports URL parameters for configuring the initial state. This is especially useful for automated testing and sharing specific configurations.Supported Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
simulation | string | First simulation | Simulation name to load |
host | 'chatgpt' | 'claude' | 'chatgpt' | Host shell (conversation chrome, theming, capabilities) |
theme | 'light' | 'dark' | 'dark' | Color theme |
displayMode | 'inline' | 'pip' | 'fullscreen' | 'inline' | App display mode |
locale | string | 'en-US' | Locale for i18n |
maxHeight | number | 600 | Max height in PiP mode |
deviceType | 'mobile' | 'tablet' | 'desktop' | 'unknown' | 'desktop' | Device type |
hover | 'true' | 'false' | 'true' | Hover capability |
touch | 'true' | 'false' | 'false' | Touch capability |
safeAreaTop | number | 0 | Top safe area inset |
safeAreaBottom | number | 0 | Bottom safe area inset |
safeAreaLeft | number | 0 | Left safe area inset |
safeAreaRight | number | 0 | Right safe area inset |
Example URLs
createSimulatorUrl
For type-safe URL generation in tests, use thecreateSimulatorUrl utility:
Import
Usage
SimulatorUrlParams Interface
E2E Testing Example
Sidebar Controls
The simulator sidebar provides interactive controls for:- Host: Switch between ChatGPT and Claude conversation shells
- Simulation: Select which simulation to display
- Simulation Width: Toggle between mobile (375px, 425px), tablet (768px), and full width (1024px)
- Theme: Toggle between light and dark themes
- Display Mode: Switch between inline, PiP, and fullscreen modes
- Locale: Set the locale string
- Max Height: Configure PiP mode height
- Device Type: Configure device type and capabilities (hover, touch)
- Time Zone: Set the IANA time zone (e.g.
America/New_York) - User Agent: Set the user agent string
- Safe Area Insets: Configure safe area insets for notch simulation
- JSON Editors: Edit tool input, tool result, and app context (model context) directly
- Send as Partial (Streaming): Send the current tool input JSON as a
tool-input-partialnotification to test streaming input handling
ChatGPT Mock Runtime
When the ChatGPT host is selected, the simulator automatically injects a mockwindow.openai runtime into the resource iframe. This enables:
isChatGPT()returnstrue— platform detection works correctly- ChatGPT-specific hooks (
useUploadFile,useGetFileDownloadUrl,useRequestModal,useRequestCheckout) work with stub implementations - All mock method calls are logged to the browser console with a
[Simulator]prefix
window.openai is not injected and ChatGPT hooks will throw if called.
See ChatGPT Hooks for the full API reference.