Skip to main content
Deploy your FrontMCP server to serverless platforms like Vercel, AWS Lambda, and Cloudflare Workers.

Supported Platforms

Quick Start

New project? Use frontmcp create with the --target flag to scaffold a serverless-ready project:
This generates the platform config files (vercel.json, ci/template.yaml, or wrangler.toml) automatically.

Vercel

Vercel is a popular platform for deploying serverless functions with excellent DX.
For persistent session storage on Vercel, see Vercel KV Setup for an edge-compatible alternative to Redis.

Setup

  1. Build your project:
  2. This generates:
  3. Deploy:

Generated vercel.json

The buildCommand and installCommand are auto-detected based on the lockfile in your project (yarn, npm, pnpm, or bun). The vercel target deploys a Node.js handler using Vercel’s Build Output API, not Vercel Edge Runtime. You can customize this file after generation — the build command will not overwrite existing config files.

How It Works

The generated index.js wrapper:
  1. Sets FRONTMCP_SERVERLESS=1 environment variable
  2. Imports your compiled main.js (which runs the @FrontMcp decorator)
  3. Exports an async handler that retrieves the Express app and forwards requests

AWS Lambda

Deploy to AWS Lambda using the Serverless Express adapter.

Prerequisites

Install the required dependency:

Setup

Projects created with frontmcp create --target lambda include a SAM template at ci/template.yaml and a deploy script:
  1. Build your project:
  2. This generates:
  3. Deploy using your preferred AWS deployment tool.

Example SAM Template

Example serverless.yml

ESM Requirements

AWS Lambda with ESM requires one of:
  • "type": "module" in your package.json
  • Using .mjs extension for handler files
  • Configuring your deployment tool for ESM
The generated dist/index.js uses ESM syntax (import/export).

Cold Start Optimization

Lambda cold starts can add latency to the first request. Consider:
  • Provisioned Concurrency: Keep instances warm
  • Smaller bundle size: Use tree-shaking and minimize dependencies
  • ARM64 architecture: Often faster cold starts than x86

Cloudflare Workers (Experimental)

Cloudflare Workers support is experimental. The Express-to-Workers adapter has limitations with streaming, certain middleware, and some response methods.For production Cloudflare deployments, consider using Hono or native Workers APIs.
Projects created with frontmcp create --target cloudflare include a wrangler.toml and a deploy script:

Limitations

  • Basic request/response handling only
  • No streaming support
  • Limited Express middleware compatibility
  • Missing some response methods (redirect(), type(), etc.)

Setup

  1. Build your project:
  2. This generates:
  3. Deploy:

Generated wrangler.toml

Storage Considerations

Serverless environments require distributed storage since each invocation may run on a different instance.

Storage Configuration

Plugin Storage

Plugins like RememberPlugin and CachePlugin can use type: 'global-store' to automatically use the FrontMcp-level storage configuration:
In-memory storage does not work reliably in serverless environments. Each invocation may create a new instance with empty memory. Always use a distributed storage backend.

How Serverless Mode Works

Architecture

Environment Variable

The FRONTMCP_SERVERLESS=1 environment variable triggers serverless mode:

Troubleshooting

”Serverless handler not initialized”

Causes:
  • The @FrontMcp decorator wasn’t executed before the handler was called
  • FRONTMCP_SERVERLESS=1 is not set in the entry point
Solutions:
  • Ensure your main.ts/main.js has the @FrontMcp decorator on a class
  • Verify the generated index.js sets the environment variable before importing main.js

”Module not found: @codegenie/serverless-express”

The Lambda adapter requires an additional dependency:

Cold Start Performance

First requests may be slow due to initialization. Strategies:

TypeScript Compilation Errors

If you see module-related errors:
  • The adapter sets the correct module format automatically
  • --module esnext for Vercel/Lambda
  • --module commonjs for Node.js/Cloudflare
Ensure your tsconfig.json doesn’t conflict. The CLI arguments override tsconfig settings.

API Reference

CLI Commands

SDK Exports