Overview
Simulations define test scenarios for your resources—combining tool definitions, mock data, and platform state. They can be used with the ChatGPTSimulator for local development or runMCPServer for platform testing.- Framework (JSON)
- Library (TypeScript)
In the sunpeak framework, simulations are JSON files with auto-discovery. The resource component and metadata are automatically linked based on filename prefix.For example:Each simulation can have different
File Naming Convention
Simulation files follow the pattern:albums-show-simulation.json- linked toalbums-resource.tsxreview-diff-simulation.json- linked toreview-resource.tsxreview-post-simulation.json- linked toreview-resource.tsx
{resource} prefix determines which resource files are automatically linked:- Component:
src/resources/{resource}-resource.tsx - Metadata:
src/resources/{resource}-resource.json
albums-show-simulation.json and albums-empty-simulation.json).JSON Schema
Each simulation JSON file contains:Auto-Discovery
The framework automatically discovers and links simulations:- Discovery: Glob pattern
src/simulations/*-simulation.json - Matching: Longest prefix match links to resources (e.g.,
albums-showmatchesalbums-resource.tsx) - No imports needed: Everything is wired automatically
- Import resource metadata into simulations
- Specify
resourcein the simulation JSON - Maintain an index file of simulations
Multiple Scenarios
Create multiple simulations per resource to test different scenarios:callToolResult.structuredContent to test various data scenarios.Properties
Unique identifier for the simulation. Used to select simulations in the UI and URL parameters. (Library only - auto-generated from filename in framework)
The React component to render for this simulation. (Library only - auto-linked in framework)
A decorative message shown in the simulator interface. Has no functional purpose.
MCP Tool definition from
@modelcontextprotocol/sdk. Defines the tool’s name, description, input schema, and metadata.MCP Resource definition from
@modelcontextprotocol/sdk. Defines the resource’s name, URI, MIME type, and metadata. (Library only - auto-linked in framework)Mock data for the MCP CallTool response. The
structuredContent property is passed to your component via useWidgetProps().Mock input parameters for the tool call. The
arguments property is accessible via useToolInput().Initial widget state for the simulation. Accessible via
useWidgetState().MCP SDK Types
The simulation interface uses official types from@modelcontextprotocol/sdk:
Tool
Resource
CallToolResult
OpenAI-Specific Metadata
When targeting ChatGPT, include OpenAI-specific metadata in the_meta fields:
Tool _meta
Resource _meta
See Also
ChatGPTSimulator
Component API reference.
runMCPServer
MCP server API reference.