- A DSN — one connection string for a single database.
- A TOML file — passed with
--config, for one or more databases plus per-source and per-tool settings.
--config and --dsn cannot be combined.
Environment variables are a different matter: DSN and DB_* stay available to a TOML file through ${VAR} interpolation, which is the recommended way to keep credentials out of the file.
When you use a DSN, DBHub takes it from the first of:
--dsnflagDSNenvironment variableDB_*environment variables.envfile (.env.localin development,.envin production)
- Command-line flag
- Environment variable
.envfile- Built-in default
—transport
string
default:"stdio"
Transport protocol for MCP communication. Env:
TRANSPORT.Options:stdio- For desktop tools (Claude Desktop, Claude Code, Cursor). Pure MCP-over-stdio with no HTTP server.http- For browser and network clients. Starts HTTP server with MCP endpoint, workbench, and API.
http, 2026-era clients send the standard Mcp-Method / Mcp-Name headers with every request, so a fronting gateway or WAF can route and rate-limit individual tools without parsing request bodies.—port
number
default:"8080"
HTTP server port. Only used when
--transport=http. Ignored for stdio transport. Env: PORT.—host
string
default:"0.0.0.0"
HTTP bind address. Only used when
--transport=http. Ignored for stdio transport. Env: DBHUB_HOST.—allowed-hosts
string
default:"(loopback + this machine)"
Comma-separated list of additional hostnames the HTTP transport accepts in the
Host (and Origin) headers. This is DBHub’s DNS-rebinding protection:
requests whose Host is not on the list are rejected with 403, so a
malicious web page cannot rebind a hostname to your DBHub instance and drive
its MCP tools from the victim’s browser. Only used when --transport=http. Env: DBHUB_ALLOWED_HOSTS.The list always includes loopback (localhost, 127.0.0.1, [::1]). When
bound to a wildcard address (the default 0.0.0.0 / ::), this machine’s own
hostname and external IP addresses are added automatically, so reaching DBHub
by IP or machine name works without any extra configuration. You only need
this flag for other names that resolve to DBHub — most commonly a
reverse-proxy or public DNS name.A port in an entry is ignored — only the hostname is matched. IPv6 literals
must be bracketed, e.g.
[2001:db8::1]. The active allow-list is printed at
startup. If a legitimate client gets a 403 “Host … is not allowed”, add
its hostname here.—auth-token
string
Comma-separated list of bearer tokens required on every HTTP request. Only used when Client request (
--transport=http. Unset by default — auth is off unless you configure this. Env: DBHUB_AUTH_TOKEN.Clients must send a matching token as Authorization: Bearer <token>; requests without one get 401 Unauthorized with a WWW-Authenticate: Bearer header. /healthz is exempt so uptime monitors don’t need a token./api/sources is a plain GET; the MCP endpoint itself
requires a JSON-RPC POST body, so it’s not a copy-pasteable example):Configuring a token is the opt-in — there’s no separate “require auth” flag to remember. A comma-separated list lets you rotate a leaked or expiring token by adding the new one, redeploying, and then removing the old one, and lets you hand different tokens to different clients so one can be revoked without affecting the others.
—dsn
string
Database connection string (Data Source Name). Format: DSN Query Parameters:
database_type://username:password@host:port/database_name?options. Env: DSN (see the resolution order at the top of this page).- PostgreSQL
- MySQL
- MariaDB
- SQL Server
- SQLite
SSL/TLS Options:
sslmode=disable: All SSL/TLS encryption is turned off. Data is transmitted in plaintext.sslmode=require: Connection is encrypted, but the server’s certificate is not verified.sslmode=verify-ca: SSL with CA certificate verification, but no hostname check. PostgreSQL only. Usesslrootcertto specify the CA certificate path.sslmode=verify-full: SSL with CA certificate and hostname verification. PostgreSQL only. Usesslrootcertto specify the CA certificate path.
environment
Recommended for databases with complex passwords containing special characters:
—id
string
Instance identifier to suffix tool names. Useful when running multiple DBHub instances (e.g., in Cursor). Env: Result:
ID.Tools will be named execute_sql_{id} for each instance.execute_sql_prod and execute_sql_staging tools—demo
boolean
default:"false"
Run DBHub with a bundled SQLite sample “employee” database for testing.
—config
string
Path to a TOML configuration file, for managing multiple database connections and advanced configurations.See TOML Configuration for the complete reference, including source options, tool options, SSH tunnels, and custom tools.
SSH Tunnel Options
SSH tunnel configuration for connecting to databases through bastion/jump hosts.
Examples:
--ssh-key/SSH_KEYaccepts either a file path or a base64-encoded private key. DBHub automatically detects the format: it first tries to read the value as a file path, and if that fails, decodes it as base64.- When
--ssh-hostis a plain alias (no dots, not an IP address), DBHub automatically resolves it from~/.ssh/config, reading theHostName,User,IdentityFile, andProxyJumpdirectives. Explicit flags always override values from the config file. ProxyJumphops that are themselves~/.ssh/configaliases are resolved recursively — each hop uses its ownHostName/User/Port/IdentityFile(and its own nestedProxyJump), matching howsshconnects. CyclicProxyJumpchains are rejected with an error.- ProxyCommand is not supported (requires shell execution). Use ProxyJump instead.
- Path expansion for
~/is supported in file paths.