Overview
TheInspector 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 inspector supports multiple host shells — switch between ChatGPT and Claude conversation chrome, theming, and reported capabilities from the sidebar or via URL parameters.
Import
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 inspector UI.
Optional icon (emoji) displayed in the inspector UI.
Optional children to render when no simulations are selected.
onCallTool
(params: { name: string; arguments?: Record<string, unknown> }) => Promise<CallToolResult> | CallToolResult
Handler for tool calls. When the user clicks Run, or when the app calls
callServerTool, calls are forwarded to this callback. The sunpeak dev command wires this up automatically.onCallToolDirect
(params: { name: string; arguments?: Record<string, unknown> }) => Promise<CallToolResult> | CallToolResult
Direct tool handler call, bypassing MCP server mock data. Used by the Run button to call real handlers. Falls back to
onCallTool if not provided.Initial state of the Prod Resources toggle. When
true, the inspector loads resources from dist/ production builds instead of HMR. Set by the --prod-resources CLI flag.Hide the Prod Resources checkbox in the sidebar. Used in standalone inspect mode where Prod Resources is not applicable.
URL Parameters
The Inspector 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 |
|---|---|---|---|
tool | string | First tool | Tool name to select. When specified without simulation, no mock data is loaded (“Press Run” state). |
simulation | string | First fixture | Simulation fixture name to load. Mock data renders immediately. |
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 |
prodResources | 'true' | 'false' | 'false' | Enable Prod Resources mode (dist/ bundles) |
Example URLs
createInspectorUrl
For type-safe URL generation in tests, use thecreateInspectorUrl utility:
Import
Usage
InspectorUrlParams Interface
E2E Testing Example
Sidebar Controls
The inspector sidebar provides interactive controls for:- Prod Tools: Toggle Prod Tools mode — calls real tool handlers instead of simulation mocks (requires
onCallToolprop) - Prod Resources: Toggle Prod Resources mode — loads production-built HTML from
dist/instead of Vite HMR - Host: Switch between ChatGPT and Claude conversation shells
- Simulation / Tool: Select which simulation (or tool, in Prod Tools mode) to display
- 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 inspector automatically injects a mockwindow.openai runtime into the resource iframe. This enables:
isChatGPT()returnstrue— host detection works correctly- ChatGPT-specific hooks (
useUploadFile,useRequestModal,useRequestCheckout) work with stub implementations - All mock method calls are logged to the browser console with a
[Inspector]prefix
window.openai is not injected and ChatGPT hooks will throw if called.
See ChatGPT Hooks for the full API reference.