Supported Platforms
| Platform | Status | Module Format | Config File |
|---|---|---|---|
| Vercel | Stable | ESM | vercel.json |
| AWS Lambda | Stable | ESM | ci/template.yaml (SAM) |
| Cloudflare Workers | Experimental | CommonJS | wrangler.toml |
Quick Start
- Vercel
- AWS Lambda
- Cloudflare
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
-
Build your project:
-
This generates:
-
Deploy:
Generated vercel.json
You can customize this file after generation. The build command will not overwrite existing config files.
How It Works
The generatedindex.js wrapper:
- Sets
FRONTMCP_SERVERLESS=1environment variable - Imports your compiled
main.js(which runs the@FrontMcpdecorator) - 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
-
Build your project:
-
This generates:
- 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 yourpackage.json- Using
.mjsextension for handler files - Configuring your deployment tool for ESM
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)
Limitations
- Basic request/response handling only
- No streaming support
- Limited Express middleware compatibility
- Missing some response methods (
redirect(),type(), etc.)
Setup
-
Build your project:
-
This generates:
-
Deploy:
Generated wrangler.toml
Storage Considerations
Serverless environments require distributed storage since each invocation may run on a different instance.Recommended Storage by Platform
| Platform | Recommended Storage | Notes |
|---|---|---|
| Vercel | Vercel KV or Upstash | Edge-compatible REST APIs |
| AWS Lambda | ElastiCache Redis or Upstash | VPC-accessible |
| Cloudflare | Cloudflare KV or Upstash | Workers KV for simple cases |
Storage Configuration
- Vercel KV
- Upstash
- Redis
Plugin Storage
Plugins like RememberPlugin and CachePlugin can usetype: 'global-store' to automatically use the FrontMcp-level storage configuration:
How Serverless Mode Works
Architecture
Environment Variable
TheFRONTMCP_SERVERLESS=1 environment variable triggers serverless mode:
Troubleshooting
”Serverless handler not initialized”
- The
@FrontMcpdecorator wasn’t executed before the handler was called FRONTMCP_SERVERLESS=1is not set in the entry point
- Ensure your main.ts/main.js has the
@FrontMcpdecorator on a class - Verify the generated
index.jssets 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:| Platform | Solution |
|---|---|
| Lambda | Provisioned Concurrency, smaller bundles |
| Vercel | Edge Functions (if applicable) |
| Cloudflare | Workers are generally fast to cold start |
TypeScript Compilation Errors
If you see module-related errors:- The adapter sets the correct module format automatically
--module esnextfor Vercel/Lambda--module commonjsfor Node.js/Cloudflare
tsconfig.json doesn’t conflict. The CLI arguments override tsconfig settings.