A web-accessible, fully-editable project dashboard backed by Neon (Postgres). Both the web UI and a CLI write to the same database, so AI agents have a centralized, integrated place to track project state.
Stack: Next.js 16 (App Router) · Neon serverless + Drizzle ORM · BetterAuth (Google OAuth,
locked to you@example.com) · Vercel.
cp .env.example .env.localand fill it in (see below).npm installnpm run db:migrate— apply migrations to Neon (run as the owner role).npm run dev— open http://localhost:3030 and sign in with Google asyou@example.com.
Useful: npm run db:studio (Drizzle Studio), npm run db:generate (regenerate migration SQL
after a schema change).
| Role | Env var | Where | Access |
|---|---|---|---|
| owner | DATABASE_URL |
local / CI only | everything — migrations + seed |
| app | DATABASE_URL in Vercel |
Vercel env only | read/write all tables incl. auth |
| agent | AGENT_DATABASE_URL |
local CLI / agents | projects + tasks + runs + events; no auth tables |
Create the scoped agent role once (psql as owner):
CREATE ROLE mc_agent LOGIN PASSWORD '…';
GRANT USAGE ON SCHEMA public TO mc_agent;
GRANT SELECT, INSERT, UPDATE, DELETE ON projects, tasks TO mc_agent;
-- Mission Control: runs/events are append-only / update-only — no DELETE. events.seq is a
-- GENERATED-AS-IDENTITY column, so table INSERT suffices (no sequence grant needed).
GRANT SELECT, INSERT, UPDATE ON runs, events TO mc_agent;
REVOKE ALL ON users, sessions, accounts, verification FROM mc_agent;Migration
0023_reapply_agent_grants_dual_nameapplies the schema USAGE + projects/tasks (full) + runs/events (no DELETE) grants automatically — but only if themc_agent(or legacycc_agent) role already exists (apg_roles-guardedDOblock). Create the role BEFORE running migrations on a fresh DB, or re-run theGRANTs above once after. (The early0001/0002/0004grant migrations guard only the legacycc_agentname, so on a rebuilt DB they no-op formc_agent— which is why0023exists.)
After any future migration that adds an agent-facing table, re-run the GRANT (or set
ALTER DEFAULT PRIVILEGES FOR ROLE <owner> IN SCHEMA public GRANT SELECT,INSERT,UPDATE,DELETE ON TABLES TO mc_agent;).
Requires the scoped AGENT_DATABASE_URL. It does not silently fall back to DATABASE_URL
(which may be the owner role) — with only DATABASE_URL set, mc refuses to run (exit 4) unless
you opt in with MC_ALLOW_DATABASE_URL_FALLBACK=1 (not recommended). See cli/README.md.
npm run cli -- project list --json
npm run cli -- task add my-project "Wire up billing"Beyond the project/task catalog, the CLI also drives Mission Control — agent runs, the
activity-event log, and the cost rollup — plus self-dispatch (task next/task claim) and
self-sourcing (task import-issues):
npm run cli -- run list --active --json # what's running right now
npm run cli -- task next --json # next claimable task (FIFO)
npm run cli -- spend --group-by agent --json # cost rollup, by agentThe full command catalog (every flag, with readonly tags) is in cli/README.md
and at runtime via mc spec --json.
- Sign-in is Google OAuth, restricted to
you@example.com, enforced both at user-creation (databaseHooks.user.create.before, fail-closed) and per-request (requireAllowedUser()in every server action and the dashboard page). Middleware is only a redirect convenience, not the security boundary. - Threat model for
AGENT_DATABASE_URL: anyone holding it can read/write all project and task data and bypasses the email allowlist for the write path. It cannot read sessions or accounts (auth tables are revoked). Treat it as a sensitive credential; never set it in Vercel.
- Set in Vercel (Production):
DATABASE_URL(the app role, not owner),BETTER_AUTH_SECRET,BETTER_AUTH_URL+NEXT_PUBLIC_BETTER_AUTH_URL(prod origin),GOOGLE_CLIENT_ID/SECRET,ALLOWED_EMAIL. Do not setAGENT_DATABASE_URLor the owner string there. - Add the production callback to Google Cloud authorized redirect URIs:
https://<prod-domain>/api/auth/callback/google. - Node is pinned to 22.x via
enginesinpackage.json. - For future schema changes: run
npm run db:migrate(owner, local/CI) and re-grant the agent role before promoting code that depends on the new schema.