Quick Start
1. Build for Vercel
Run the build command with the--vercel flag:
.vercel/output directory following Vercel’s Build Output API specification.
2. Deploy
Deploy using the Vercel CLI:How It Works
The--vercel flag triggers the build process defined in build-vercel-output.ts:
Output Structure
The build process creates the following structure:Function Configuration
The.vc-config.json file specifies the runtime:
Routing Configuration
Theconfig.json defines request routing:
- Serves static auth assets from
/auth/assets/ - Handles filesystem requests (static files)
- Routes auth pages to the auth UI
- Routes all other requests to your MCP server at
/api
Environment Variables
Configure environment variables in your Vercel project settings orvercel.json.
Example: API Key Authentication
vercel.json
xmcp.config.ts
Common Environment Variables
| Variable | Purpose | Example |
|---|---|---|
PORT | Server port (auto-set by Vercel) | 3000 |
API_KEY | API key for authentication | your-secret-key |
JWT_SECRET | JWT signing secret | your-jwt-secret |
VERCEL | Vercel environment detection | 1 |
The
VERCEL=1 environment variable is automatically set by Vercel. You don’t need to add the --vercel flag in your build command when deploying to Vercel.Package.json Configuration
Update yourpackage.json with build scripts:
package.json
When deploying via Vercel’s platform, the
VERCEL=1 environment variable automatically triggers Vercel-specific builds, so you can use xmcp build without the flag.vercel.json Example
A completevercel.json configuration:
vercel.json
Using with Next.js
If you’re integrating xmcp with Next.js, use the adapter approach:xmcp.config.ts
package.json
When using the adapter, xmcp will not create the
.vercel/output directory. Instead, it integrates with Next.js’s own Vercel deployment.Troubleshooting
Build Fails: “Dist directory not found”
Ensure you runxmcp build before xmcp build --vercel, or just use xmcp build --vercel which includes the standard build:
Auth UI Not Serving
The auth UI assets are automatically detected from:dist/auth-ui/(if present after build)node_modules/@xmcp-dev/better-auth/dist/auth-ui/(fallback)
Routes Not Working
Check theconfig.json routing rules. Custom routes can be added by modifying the build script or creating a custom vercel.json.
Next Steps
Authentication
Add authentication to your server
Cloudflare Workers
Deploy to Cloudflare instead
Middleware
Add custom middleware
Configuration
Configure your xmcp server