Skip to main content
Sheetbase Docs
Guides

Self-Deploy

Run your own Sheetbase instance on Vercel. All required environment variables and database setup steps.

Note

The hosted instance at sheetbase.flonest.app is the easiest way to get started. Self-deploy is for teams who need data sovereignty, custom domain, or want to extend the tool surface.


Prerequisites

  • Vercel account (Hobby or Pro)
  • Supabase project (free tier works)
  • Google Cloud Console project with Sheets API + Drive API enabled

Step 1 — Clone and set up the repo

git clone https://github.com/<your-fork>/sheets-mcp
cd Sheetbase
npm install

Step 2 — Create your Supabase project

  1. Go to supabase.com → New project
  2. Copy the connection string (Settings → Database → Connection string → URI mode)
  3. Copy the Project URL and anon key (Settings → API)

Run the database migrations

For a new, empty database, apply the complete historical bootstrap once, then upgrade it to the current OAuth Provider schema:

psql $DATABASE_URL -f better-auth_migrations/2026-04-13T06-41-17.610Z.sql
psql $DATABASE_URL -f migrations/2026-07-18-better-auth-oauth-forward.sql

The later Better Auth bootstrap is a complete copy of the earlier bootstrap plus apikey. Do not run both bootstrap files; their CREATE TABLE statements conflict.

Then apply the SheetBase cache, history, index, and restricted SQL role in this order:

psql $DATABASE_URL -f scripts/slice2_sheet_snapshots.sql
psql $DATABASE_URL -f scripts/slice1_write_history.sql
psql $DATABASE_URL -f scripts/slice3_gin_index.sql
psql $DATABASE_URL -f scripts/slice4_role_isolation.sql

Warning: slice4_role_isolation.sql creates the sheet_analyzer Postgres role used by analyze_range and transform_range. This must be applied — without it, all SQL tool calls will fail with a role "sheet_analyzer" does not exist error.

The custom SheetBase scripts are idempotent. The OAuth forward migration is a one-time guarded migration and intentionally refuses to run when its expected legacy starting schema is absent or already upgraded.


Step 3 — Configure Google OAuth

  1. Go to Google Cloud Console → APIs & Services → Credentials
  2. Enable: Google Sheets API and Google Drive API
  3. Create OAuth 2.0 Client ID (Web Application)
  4. Add Authorized redirect URI: https://<your-vercel-domain>/api/auth/callback/google
  5. Copy the Client ID and Client Secret

Note

If your Google OAuth consent screen is in "Testing" mode, add your email (and any test users) under the OAuth consent screen → Test users. Apps in Testing mode only allow listed test users.


Step 4 — Set environment variables

In Vercel → Project Settings → Environment Variables, add:

VariableValue
DATABASE_URLSupabase Postgres connection string (URI mode)
BETTER_AUTH_URLYour Vercel deployment URL (e.g. https://your-app.vercel.app)
NEXT_PUBLIC_APP_URLSame as above
GOOGLE_CLIENT_IDFrom Google Cloud Console
GOOGLE_CLIENT_SECRETFrom Google Cloud Console
BETTER_AUTH_SECRETAny strong random string (32+ chars) — used to sign sessions
NEXT_PUBLIC_SUPABASE_URLSupabase Project URL
NEXT_PUBLIC_SUPABASE_ANON_KEYSupabase anon key

Warning: NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY must be set even if you don't use Supabase client-side features. The @supabase/ssr package in the dependency tree will cause a 500 error on Edge if they are missing.


Step 5 — Deploy

npx vercel --prod

The build uses next build. Vercel auto-detects Next.js 16. No special build settings needed.

Note

This self-deploy guide is for independent installations. The hosted Sheetbase product is a private internal beta using one private founder-preview runtime. An approved merge to main automatically releases through the guarded repository workflow. A non-ADMIN merge first creates one ADMIN-attributed empty commit; its second workflow run performs the complete release.


Step 6 — Update your MCP config

Replace the hosted URL with your own:

{
  "mcpServers": {
    "sheetbase": {
      "url": "https://your-app.vercel.app/api/mcp"
    }
  }
}

Verify the deployment

Hit the OIDC discovery endpoint to confirm the proxy is working:

curl https://your-app.vercel.app/.well-known/oauth-authorization-server

Should return a JSON object with issuer, authorization_endpoint, token_endpoint, etc.

Then visit https://your-app.vercel.app/login and sign in with Google to verify the full auth flow.


Troubleshooting

ProblemFix
role "sheet_analyzer" does not existRun scripts/slice4_role_isolation.sql against your Supabase DB
500 on every requestCheck NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are set in Vercel env vars
Google OAuth redirect mismatchVerify the redirect URI in Google Cloud Console matches your exact Vercel domain
invalid_grant on token refreshBETTER_AUTH_SECRET changed between deployments — all existing sessions invalidated
BETTER_AUTH_URL mismatchMust match the URL your app is deployed to exactly (no trailing slash)

On this page