Skip to main content

Overview

When you create a new project with sunpeak new, the sunpeak framework gives you a minimal, convention-based project structure with everything needed for MCP App development.
sunpeak-app/
├── src/
   ├── resources/
   └── review/
       └── review.tsx                   # Review UI component + resource metadata.
   ├── tools/
   ├── review-diff.ts                   # Tool with handler, schema, and optional resource link.
   ├── review-post.ts                   # Multiple tools can share one resource.
   └── review.ts                        # Backend-only tool (no resource, no UI).
   └── server.ts                            # Optional: auth, server config.
├── tests/
   ├── simulations/
   ├── review-diff.json                 # Mock state for testing (includes serverTools).
   ├── review-post.json                 # Mock state for testing (includes serverTools).
   └── review-purchase.json             # Mock state for testing (includes serverTools).
   ├── e2e/
   └── review.spec.ts                   # Playwright tests against the inspector.
   └── live/
       └── review.spec.ts                   # Live tests against real ChatGPT (one per resource).
└── package.json

Key Files & Directories

  • src/resources/ - Directory containing all your MCP Resources (MCP App UIs).
    • Each resource lives in its own folder: src/resources/{name}/
    • Each folder contains:
      • {name}.tsx - React component + resource metadata (export const resource: ResourceConfig)
      • components/ - Optional subfolder for resource-specific components
  • src/tools/ - Directory containing MCP tool files.
    • Each tool is a .ts file that exports tool (metadata with optional resource link), schema (Zod), and a default handler. Tools without a resource field are registered as plain MCP tools (no UI).
    • Multiple tools can reference the same resource.
  • src/server.ts - Optional server entry for auth and server configuration.
  • tests/simulations/ - Directory containing simulation files for local development and testing.
    • Simulation files are flat *.json files with a tool string field referencing a tool filename.
    • Any filename works — multiple simulations can reference the same tool.
  • tests/e2e/ - Directory containing end-to-end Playwright tests for each resource. Uses the Inspector to test your resources render properly across hosts (ChatGPT, Claude) and states (tool calls, saved state, dark mode, pip display mode, etc.).
  • tests/live/ - Directory containing live tests that run against real ChatGPT. These tests open your browser, send messages to ChatGPT, and validate your app renders correctly in the real host environment.
No entry point files needed! The framework automatically discovers your resources, tools, and simulations using conventions.

Examples

Example sunpeak resource, tool, & simulation files for an MCP App called “Review”.

Resource

Each resource .tsx file exports both a ResourceConfig metadata object and the React component:
// src/resources/review/review.tsx

import { useToolData } from 'sunpeak';
import type { ResourceConfig } from 'sunpeak';

export const resource: ResourceConfig = {
  description: 'Visualize and review a code change',
  _meta: { ui: { csp: { resourceDomains: ['https://cdn.example.com'] } } },
};

export function ReviewResource() {
  const { output: data } = useToolData<unknown, { title: string }>();

  return <h1>Review: {data?.title}</h1>;
}

Tool

Each tool .ts file exports metadata (with a resource name), a Zod schema, and a handler:
// src/tools/review-diff.ts

import { z } from 'zod';
import type { AppToolConfig, ToolHandlerExtra } from 'sunpeak/mcp';

export const tool: AppToolConfig = {
  resource: 'review',
  title: 'Diff Review',
  description: 'Show a review dialog for a proposed code diff',
  annotations: { readOnlyHint: false },
  _meta: { ui: { visibility: ['model', 'app'] } },
};

export const schema = {
  changesetId: z.string().describe('Unique identifier for the changeset'),
  title: z.string().describe('Title describing the changes'),
};

type Args = z.infer<z.ZodObject<typeof schema>>;

export default async function (args: Args, extra: ToolHandlerExtra) {
  return { structuredContent: { title: args.title, sections: [] } };
}

Simulation

Simulation files provide fixture data for testing. Each references a tool by filename and contains the mock input/output:
// tests/simulations/review-diff.json

{
  "tool": "review-diff",                      // References src/tools/review-diff.ts
  "userMessage": "Refactor the auth module to use JWT tokens.",
  "toolInput": {
    "changesetId": "cs_789",
    "title": "Refactor Authentication Module"
  },
  "toolResult": {
    "structuredContent": {
      "title": "Refactor Authentication Module"
      // ...
    }
  }
}

Included Tooling

The template includes minimal, essential tooling:

Vite

Fast build tool with hot-reload (HMR) for instant development feedback. The framework owns the dev server configuration - just run sunpeak dev.

Tailwind CSS 4

Utility-first CSS framework for rapid UI development. Pre-configured via Vite plugin.

TypeScript

Type safety with TypeScript 5. Configured via tsconfig.json.

Vitest (Unit Tests)

Vite-native testing framework for component testing. Run with pnpm test.

Playwright (E2E Tests)

End-to-end testing against the ChatGPT Inspector. Tests live in tests/e2e/. Run with pnpm test:e2e.

Playwright (Live Tests)

Automated testing against real ChatGPT. Tests live in tests/live/. Run with pnpm test:live. See the Testing Guide for setup details.

Add Your Own Tooling

The template is intentionally minimal. Add your preferred tools as needed:
  • Linting: ESLint
  • Formatting: Prettier
  • Type checking: Run tsc --noEmit as a script

sunpeak CLI API Reference

All sunpeak CLI commands and configurations.