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

# Production Build

> Build, bundle, and deploy your FrontMCP server for production

Build a compact Node artifact and run it behind a process manager / reverse proxy.

<Tip>
  Looking to deploy to serverless platforms like Vercel, AWS Lambda, or Cloudflare Workers?
  See the [Serverless Deployment](/frontmcp/deployment/serverless) guide.
</Tip>

## Build

<CodeGroup>
  ```bash npm theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
  npm run build
  ```

  ```bash yarn theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
  yarn build
  ```

  ```bash pnpm theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
  pnpm build
  ```
</CodeGroup>

This compiles TypeScript to `dist/` using your project's `tsconfig.json` (the
CLI passes `--project tsconfig.json` when present, otherwise falls back to
inline `tsc` flags).

## Start

`frontmcp create` and `frontmcp init` don't add a `start` script by default —
run the compiled bundle directly. The default `node` target emits a CommonJS
single-file bundle at `dist/{name}.bundle.js` (where `{name}` is your
`package.json` name):

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
NODE_ENV=production PORT=8080 node dist/my-server.bundle.js
```

If you prefer a script, add one to `package.json`:

```json theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
{
  "scripts": {
    "start": "node dist/my-server.bundle.js"
  }
}
```

## Recommended runtime setup

* Use a **process manager** (PM2, systemd) for restarts and logs.
* Put a **reverse proxy** (NGINX, Traefik, Caddy) in front for TLS and path routing.
* Pin matching versions of all `@frontmcp/*` packages.

### Example NGINX snippet

```nginx theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
server {
  listen 443 ssl;
  server_name mcp.example.com;

  location /mcp/ {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_pass http://127.0.0.1:8080/mcp/;
  }
}
```

## Troubleshooting

* **Version mismatch** at boot → align all `@frontmcp/*` versions and reinstall.
* **No decorators** working → ensure `experimentalDecorators` + `emitDecoratorMetadata` and `import 'reflect-metadata'` at the top of `main.ts`.
* **Port conflicts** → set `http.port` in `@FrontMcp` or use `PORT` env.
