Overview
Thesunpeak build command creates optimized, production-ready bundles for your MCP Resources. Each Resource file is built as a separate, standalone HTML bundle.
Output
The build process creates:- One HTML file per resource - A minified IIFE bundle (
es2020target) in a single inline<script>, with the compiled CSS injected by that script. There are no separate JS, CSS, or chunk files, because hosts receive the View as HTML text fromresources/read. - Inlined assets - Images and other files imported from your source are embedded as base64 data URIs. Host large images on a CDN and allow the domain in
_meta.ui.csp.resourceDomainsinstead. See Performance. - Versioned resource URIs - Each resource’s metadata gets a
ui://{name}-{timestamp}URI, so hosts that cache resource HTML pick up the new build after a deploy. - No source maps - Production bundles don’t include source maps.
Output Directory
src/resources/{name}/ is built to dist/{name}/, containing the HTML bundle and metadata. The .json file is extracted from the resource export in your .tsx file. Simulation files are not included in the build output.
Tool & Server Compilation
In addition to resource HTML bundles, the build compiles server-side code:- Tools — Each
src/tools/*.tsfile is compiled via esbuild todist/tools/{name}.js. These are ESM bundles with relative imports resolved andnode_modulesresolved at runtime. - Server entry — If
src/server.tsexists, it’s compiled todist/server.js.
sunpeak start to run your production MCP server.
Automatic Discovery
The build automatically discovers and builds all resource folders:src/resources/search/→dist/search/search.html+dist/search/search.jsonsrc/resources/calendar/→dist/calendar/calendar.html+dist/calendar/calendar.json
Metadata JSON Files
The build extracts theresource export from each .tsx file and writes it to a JSON file with a generated uri field:
uri is generated using the resource name and a build timestamp for cache invalidation.
App Identity
Each built resource is wrapped in anAppProvider that identifies the app to the host during the ui/initialize handshake. The name and version are read from your project’s package.json:
search, calendar, and map resources will all report appInfo: { name: "my-weather-app", version: "1.2.0" } to the host.
Build Optimizations
Tree Shaking
Unused code is automatically removed from the bundle:CSS Purging
Tailwind CSS automatically removes unused utility classes:- Only classes actually used in your components are included
- Significantly reduces CSS file size
- No manual configuration required
Bundle Size
Dynamicimport() and React.lazy() don’t split the output, because every resource is a single file. Keep heavy dependencies in the resources that need them, or move the work to your tool handler. See MCP App Performance for size budgets and measurement.
Usage
Next Steps
After building, start the production server or deploy:sunpeak start
Start the production MCP server.
Deployment Guide
Deploy your app to production.