Database

infrastrActure uses PostgreSQL with SQL migrations and an explicit schema model.

Current State

There are two names you need to keep separate:

LayerCurrent Name
product / repo / runtime identityinfrastrActure
live PostgreSQL schema still in usemcp_manager

The schema name is still legacy on purpose. It has not been renamed yet because that requires a dedicated DB migration and rollout window.

Connection Settings

VariablePurpose
DB_HOST / POSTGRES_HOSTPostgreSQL host
DB_PORT / POSTGRES_PORTPostgreSQL port
DB_NAME / POSTGRES_DBdatabase name
DB_USER / POSTGRES_USERrole
DB_PASSWORD / POSTGRES_PASSWORDpassword
DB_SCHEMA / POSTGRES_SCHEMAschema

Core Tables

The exact schema evolves by migration, but the platform currently centers on:

TablePurpose
mcp_toolsdiscovered catalog entries
user_tool_installationsuser/tenant runtimes
shared_toolsshared tool runtime state
sandboxessandbox lifecycle
api_keysinstance-bound key hashes + tiers
oauth_statesshort-lived OAuth state
system_tool_oauth_statesshared-tool auth state tracking
infra_approval_leasesinfra SSH admin sessions
infra_ssh_audit_eventsaudited infra SSH activity
schema_migrationsmigration ledger

Migration Model

Rules:

  • ordered by filename prefix
  • applied once
  • tracked in schema_migrations
  • designed to be idempotent and operationally safe

Local Development

npm run db:up
npm run db:migrate:dev

Production

npm run db:migrate

Reference Schema

The consolidated reference is in:

Use the migrations as the source of rollout order, and schema.sql as the convenient full snapshot.