Overview
TherunMCPServer function creates an MCP server that serves your built widgets to ChatGPT. It’s designed for local development and testing against the real ChatGPT platform.
Quick Start
- Framework
- Library
The sunpeak framework handles MCP server configuration automatically:This discovers simulations in
src/simulations/, links them to resources, and serves the built widgets from dist/.Connecting to ChatGPT
Once your MCP server is running:1
Run a tunnel
Expose your local server with a tunnel:Copy the forwarding URL (e.g.,
https://abc123.ngrok.io).2
Connect to ChatGPT
Open ChatGPT in developer mode and connect your app:
- Go to
User > Settings > Apps & Connectors > Create. - Enter your tunnel URL with the
/mcppath:https://abc123.ngrok.io/mcp. - Complete the connection flow.
3
Test your widget
Send a message that triggers your tool (e.g., “show albums”) to see your widget in ChatGPT.
Configuration Options
MCPServerConfig
MCP server name displayed in ChatGPT.
MCP server version.
Server port. Can also be set via the
PORT environment variable.Array of simulations with built widget paths. Each simulation must include:
distPath(string, required) - Path to the built widget JavaScript filetool(Tool, required) - MCP Tool definitionresource(Resource, required) - MCP Resource definitioncallToolResult(CallToolResult, optional) - Mock response data
Server Endpoints
The MCP server exposes:| Endpoint | Method | Description |
|---|---|---|
/mcp | GET | SSE stream for MCP communication |
/mcp/messages | POST | Message endpoint for client requests |
How It Works
The server creates MCP Tools and Resources from your simulations:- Tools - One per simulation, using the
tooldefinition. When called, returnscallToolResult.structuredContent. - Resources - One per simulation, containing the built widget HTML/JavaScript from
distPath.
See Also
MCP Server Guide
Step-by-step guide for connecting to ChatGPT.
Simulation
Complete simulation interface documentation.