Docs

Vercel + Neon

1. Database

  1. Create a Neon project in a region close to your users (EU: aws-eu-central-1 – Frankfurt).
  2. Copy both connection strings: the pooled one (…-pooler…) and the direct one.
  3. The owner role must keep CREATEROLE – the first migration creates the read-only role x3_sql_reader used by the MCP sql_query tool.

2. API project

New Vercel project from the repository, **Root Directory apps/api**. apps/api/vercel.json already configures everything:

  • install at the repository root (npm ci), build the SDK and the API bundle,
  • one catch-all function (/(.*) → /api) with maxDuration: 300 and the migrations and SDK files included,
  • region fra1,
  • cron */15 * * * * → /v1/cron/tick.

Environment variables (Production):

X3_ENV=production
X3_DATABASE_URL=postgres://…-pooler…/neondb?sslmode=require
X3_DATABASE_URL_UNPOOLED=postgres://…/neondb?sslmode=require
X3_PUBLIC_API_URL=https://api.3x.example.com
X3_DASHBOARD_URL=https://app.3x.example.com
X3_SECRET=<32+ random characters>
X3_ENCRYPTION_KEY=<32 bytes base64>
CRON_SECRET=<random>
X3_DASHBOARD_KEY=<32+ random characters>
X3_MIGRATE_ON_BUILD=1
X3_CRON_BUDGET_MS=280000

X3_MIGRATE_ON_BUILD=1 applies pending migrations during the build (with the direct URL). Alternatively set X3_AUTO_MIGRATE=1 to migrate on the first request. Leave X3_TRUSTED_IP_HEADERS unset: on Vercel 3x uses x-real-ip,x-forwarded-for, which Vercel overwrites.

Add your domain (e.g. api.3x.example.com). The MCP URL must answer without redirect – claude.ai connectors do not follow redirects – so use the final host everywhere.

3. Dashboard project

Second Vercel project from the same repository, **Root Directory apps/dashboard**, framework Next.js:

X3_API_URL=https://api.3x.example.com
X3_DASHBOARD_KEY=<same value as on the API>

Domain e.g. app.3x.example.com (must equal X3_DASHBOARD_URL of the API).

4. First user

With X3_ALLOW_SIGNUP=1 the first visitor can sign up at /signup; disable it afterwards if the deployment is private and invite further members from Organization → Members. Configure X3_SMTP_URL and X3_MAIL_FROM so magic links and invitations are e-mailed.

Plans and background work

HobbyPro (fluid compute)
Function maxDuration60 s → set X3_CRON_BUDGET_MS=40000300 s → X3_CRON_BUDGET_MS=280000
Vercel Crononce a dayevery 15 min (as configured)
90-day ad backfill (4 platforms)several days, unless an external scheduler calls /v1/cron/tick more often≈ 20–40 min

On Hobby, edit the cron schedule in vercel.json to a daily time, and add an external scheduler (any HTTPS cron, e.g. every 5 minutes) for timely retries and ad syncs:

curl -fsS -H "Authorization: Bearer $CRON_SECRET" https://api.3x.example.com/v1/cron/tick

Details: Cron and background jobs.

Claude connector requirements

  • https://api…/mcp reachable over public IPv4 without redirect.
  • If you run a WAF or firewall, allow Anthropic's egress range 160.79.104.0/21.
  • X3_OAUTH_ISSUER only when the issuer must differ from X3_PUBLIC_API_URL.