process.env.* in src/; this page summarizes everything currently read by the code on main.
Core application
Authentication
Better Auth (optional social login)
Better Auth is initialized once at process startup insrc/betterAuth.ts. Because of that, changing any Better Auth setting still requires a restart.
For non-secret Better Auth settings, MCPHub resolves values in this order:
BETTER_AUTH_*environment variablessystemConfig.auth.betterAuth(frommcp_settings.jsonor the database-backed system config)- Built-in defaults
Better Auth currently requires PostgreSQL-backed storage in MCPHub. In practice that means
DB_URL must be configured; file-only mode does not support Better Auth sessions.
You can still store the non-secret Better Auth settings in
systemConfig.auth.betterAuth, but BETTER_AUTH_* variables now override those values at startup. A full env-only local OIDC example looks like this:
Storage
MCPHub picks file or database storage at boot:
See Database Configuration for end-to-end setup.
Smart Routing & embeddings
Smart Routing performs vector search over upstream tools to surface only the few most relevant tools for a given query. It requires Postgres + pgvector and an embedding endpoint.OpenAI
Azure OpenAI
MCPRouter (optional upstream catalog)
Configuration examples
Development
Production with database + Smart Routing
Loading order
MCPHub loads variables in this order; later sources override earlier ones:- System environment variables.
.env.local(gitignored)..env.{NODE_ENV}(e.g..env.production)..env.
dotenv-expand is enabled, so ${VAR} interpolation works inside .env* files.
Security best practices
- Never commit secrets —
.env*files are gitignored by default; keep it that way. - Always set
JWT_SECRETexplicitly in production. - Rotate bearer keys (
/api/auth/keys) and OAuth client secrets periodically. - Use Docker / Kubernetes secrets for container deployments instead of plain
-e.