Supported Platforms
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
buildCommand runs the vercel target through your package manager, detected from the lockfile:
frontmcp create --target vercel writes the same file (with a $schema line).
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 generatedserverless-setup.js + index.js wrapper:
serverless-setup.jssetsFRONTMCP_SERVERLESS=1(must be required first, before any decorators run)index.jsrequires your compiledmain.js(which runs the@FrontMcpdecorator) and re-exports an async handler that retrieves the Express app- The Vercel adapter compiles to CommonJS and bundles everything into a
single
handler.cjsvia rspack — that bundle is what Vercel actually runs
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
Module Format
Lambda, Vercel, and Cloudflare Workers builds emit CommonJS (
dist/index.js), so the bundle works without "type": "module" in package.json. If your handler must be ESM, you can use the import() form to load the bundle from an .mjs wrapper.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
Storage Configuration
- Vercel KV
- Upstash (REST)
- Redis
Vercel KV has no pub/sub, so background tasks and elicitation cannot use it. The server still starts: tasks are skipped with a
[tasks] startup warning unless you set tasks: { enabled: true } (which keeps the error), and elicitation throws ElicitationNotSupportedError only when its store actually resolves to Vercel KV. Give either feature its own backend (tasks: { redis }, or a Redis-backed elicitation) to use it on Vercel.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:
Bundle-time behavior of serverless builds
process.env.NODE_ENVstays a runtime lookup in the Vercel and Lambda bundles. It is not inlined as"production"at build time, so a deployment’s ownNODE_ENV(and the production-only checks that read it) behave the same as on a Node server.- Optional packages the server may or may not use (
@frontmcp/storage-sqlite,@frontmcp/observability,@vercel/kv,@opentelemetry/sdk-trace-base) are bundled when installed and left as a lazyrequire()when they are not, so a missing optional package no longer fails the build with “Module not found”.better-sqlite3(a native addon) is always left external.
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
Server answers 500 server_misconfigured
A configuration fault (for example a missing MCP_SESSION_SECRET or JWT_SECRET) is answered on Node, Vercel and Lambda the same way as on Workers: 500 {"error":"server_misconfigured","code":"SESSION_SECRET_REQUIRED","message":"<remedy>"}. The code is one of SESSION_SECRET_REQUIRED, JWT_SECRET_REQUIRED, JWT_SECRET_INVALID, UNENFORCED_METADATA, AUTH_CONFIGURATION_ERROR or CONFIG_INVALID; set the named variable in the platform’s environment settings and redeploy.
”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 commonjsfor all targets (Node.js, Vercel, Lambda, Cloudflare); the Vercel and Lambda adapters then bundle tohandler.cjswith rspack
tsconfig.json doesn’t conflict. The CLI arguments override tsconfig settings.