Overview
TherunMCPServer function creates an MCP server that serves your built apps to hosts like ChatGPT. It’s designed for local development and testing against real MCP App hosts.
Quick Start
- Framework
- Library
The sunpeak framework handles MCP server configuration automatically:This starts the ChatGPT simulator and an MCP server with Hot Module Reload.
The MCP server discovers simulations from
tests/simulations/{name}/ and serves the apps with automatic rebuilding.Connecting to ChatGPT
Once your MCP server is running:Run a tunnel
Expose your local server with a tunnel:Copy the forwarding URL (e.g.,
https://abc123.ngrok.io).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.
Configuration Options
MCPServerConfig
MCP server name displayed in the host.
MCP server version.
Server port. Can also be set via the
PORT environment variable.Array of simulations with built resource paths. Each simulation must include:
distPath(string, required) - Path to the built resource HTML filetool(Tool, required) - MCP Tool definitionresource(Resource, required) - MCP Resource definitiontoolResult(object, 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, returnstoolResult.structuredContent. - Resources - One per simulation, containing the built resource HTML from
distPath.
See Also
MCP Server Guide
Step-by-step guide for connecting to ChatGPT.
Simulation
Complete simulation interface documentation.