> ## Documentation Index
> Fetch the complete documentation index at: https://sunpeak.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# sunpeak start

> Start the production MCP server.

## Overview

The `sunpeak start` command starts a production MCP server that serves your built resources and executes real tool handlers. Run `sunpeak build` first to compile your resources and tools.

```bash theme={null}
sunpeak build && sunpeak start
```

## What It Does

The production server loads everything from `dist/`:

1. **Resources** — Pre-built HTML bundles from `dist/{name}/{name}.html` with metadata from `dist/{name}/{name}.json`
2. **Tools** — Compiled tool modules from `dist/tools/*.js`, registered with real handlers and Zod schemas for input validation
3. **Server entry** — Optional `dist/server.js` for authentication and server metadata

Tools are registered with the MCP protocol using `registerAppTool` from the MCP Apps SDK. When a host calls a tool, the real handler executes — not simulation fixture data.

## Options

| Option             | Short | Description                                                                                                                                                                                               |
| ------------------ | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--port <number>`  | `-p`  | Server port (default: 8000, also respects `PORT` env var)                                                                                                                                                 |
| `--host <address>` |       | Bind address (default: `0.0.0.0`, also respects `HOST` env var)                                                                                                                                           |
| `--json-logs`      |       | Output structured JSON lines to stdout/stderr                                                                                                                                                             |
| `--sse`            |       | Use SSE streaming instead of JSON responses (default: JSON)                                                                                                                                               |
| `--stateless`      |       | Stateless mode — no session tracking, fresh server per request. For serverless and horizontally-scaled deployments. See [Deployment Guide](/app-framework/guides/deployment#serverless--edge-deployment). |

## Usage

```bash theme={null}
# Default port (8000) on all interfaces
sunpeak start

# Custom port and host
sunpeak start --port 3000 --host 127.0.0.1

# Structured logging for production
sunpeak start --json-logs

# Via environment variables
PORT=3000 HOST=127.0.0.1 sunpeak start
```

## Server Endpoints

| Endpoint  | Method | Description                                           |
| --------- | ------ | ----------------------------------------------------- |
| `/health` | GET    | Health check — returns `{"status":"ok","uptime":N}`   |
| `/`       | GET    | Server info page                                      |
| `/mcp`    | POST   | Initialize a session or send messages                 |
| `/mcp`    | GET    | Open an SSE stream for server-initiated notifications |
| `/mcp`    | DELETE | Terminate a session                                   |

The `/health` endpoint is for load balancer probes, Kubernetes liveness/readiness checks, and uptime monitoring. It is always unauthenticated.

The production server uses the MCP Streamable HTTP transport. In the default stateful mode, session IDs are managed via the `mcp-session-id` header. In `--stateless` mode, only `POST /mcp` is available (no SSE streaming or session deletion).

## Authentication

If your project includes a `src/server.ts` with an `auth()` export, the production server calls it on every MCP request. See [Server Entry](/app-framework/tools/server-entry) for details.

## Testing Locally

To test production behavior locally, run the build and start commands together:

```bash theme={null}
sunpeak build && sunpeak start
```

Then expose the server with a tunnel (e.g., `ngrok http 8000`) and connect from ChatGPT.

## Related Commands

<CardGroup cols={2}>
  <Card horizontal title="sunpeak build" icon="hammer" href="/app-framework/cli/build">
    Build resources and compile tools.
  </Card>

  <Card horizontal title="Production Server API" icon="server" href="/app-framework/tools/production-server">
    createMcpHandler, createHandler, and config types.
  </Card>

  <Card horizontal title="Deployment Guide" icon="rocket" href="/app-framework/guides/deployment">
    Full deployment walkthrough with custom server examples.
  </Card>

  <Card horizontal title="sunpeak dev" icon="code" href="/app-framework/cli/dev">
    Development server with inspector.
  </Card>
</CardGroup>
