Database Connection
dsn
Database connection string (Data Source Name). Format: SSL/TLS Options
database_type://username:password@host:port/database_name?options- PostgreSQL
- MySQL
- MariaDB
- SQL Server
- SQLite
| Database | sslmode=disable | sslmode=require | Default |
|---|---|---|---|
| PostgreSQL | ✅ | ✅ | Certificate verification |
| MySQL | ✅ | ✅ | Certificate verification |
| MariaDB | ✅ | ✅ | Certificate verification |
| SQL Server | ✅ | ✅ | Certificate verification |
| SQLite | ❌ | ❌ | N/A (file-based) |
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.
Environment Variables
Recommended for databases with complex passwords containing special characters:Database type:
postgres, mysql, mariadb, sqlserver, sqliteDatabase server hostname (not needed for SQLite)
Database server port. Default: PostgreSQL (
5432), MySQL/MariaDB (3306), SQL Server (1433)Database username (not needed for SQLite)
Database password (not needed for SQLite). Supports special characters without URL encoding.
Database name or SQLite file path
General
transport
Transport protocol for MCP communication.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, admin console, and API.
| Feature | stdio | http |
|---|---|---|
| MCP communication | stdin/stdout | HTTP POST /mcp |
| Admin console | ❌ | ✅ http://host:port/ |
| Health check | ❌ | ✅ /healthz |
| API | ❌ | ✅ /api/xxx |
| Multiple instances | ✅ No port conflicts | Requires different ports |
port
HTTP server port. Only used when
--transport=http. Ignored for stdio transport.id
Instance identifier to suffix tool names. Useful when running multiple DBHub instances (e.g., in Cursor).Tools will be named Result:
execute_sql_{id} for each instance.execute_sql_prod and execute_sql_staging toolsCannot be used with
--config (TOML configuration). TOML config defines source IDs directly in the configuration file. Use command-line DSN configuration instead if you need the --id flag.config
Path to TOML configuration file for managing multiple database connections.Automatically loads See Multi-Database Setup for TOML configuration details.
./dbhub.toml if it exists in the current directory.demo
Run DBHub with a bundled SQLite sample “employee” database for testing.The demo database includes tables for employees, departments, salaries, titles, and more.
SSH Tunnel
ssh-host
SSH server hostname for tunnel connection. Can also use SSH config host aliases from See SSH Tunnel for detailed SSH configuration examples.
~/.ssh/config.ssh-port
SSH server port.
ssh-user
SSH username.
ssh-password
SSH password for password authentication.
ssh-key
Path to SSH private key file for key-based authentication.DBHub automatically tries common default locations (
~/.ssh/id_rsa, ~/.ssh/id_ed25519, etc.) if not specified.ssh-passphrase
Passphrase for encrypted SSH private key.
Configuration Priority
DBHub follows this priority order for configuration:- Command-line arguments (highest priority)
- TOML config file (if
--configis provided or./dbhub.tomlexists) - Environment variables
.envfiles (.env.localin development,.envin production)
Mutually Exclusive Options
--config (TOML) is mutually exclusive with:--dsn- TOML configuration defines database connections directly--id- TOML configuration defines source IDs directly in the file
--id or --dsn, use command-line/environment configuration instead.Quick Reference
| CLI Option | Env | Type | Default | Description |
|---|---|---|---|---|
--dsn | DSN | string | Required* | Database connection string |
| - | DB_TYPE | string | - | Database type: postgres, mysql, mariadb, sqlserver, sqlite |
| - | DB_HOST | string | - | Database hostname |
| - | DB_PORT | number | Varies | Database port |
| - | DB_USER | string | - | Database username |
| - | DB_PASSWORD | string | - | Database password |
| - | DB_NAME | string | - | Database name or SQLite file path |
--transport | TRANSPORT | string | stdio | Transport mode: stdio or http |
--port | PORT | number | 8080 | HTTP server port |
--demo | - | boolean | false | Use sample employee database |
--id | ID | string | - | Instance identifier for tool names |
--config | - | string | ./dbhub.toml | Path to TOML config file |
--ssh-host | SSH_HOST | string | - | SSH server hostname |
--ssh-port | SSH_PORT | number | 22 | SSH server port |
--ssh-user | SSH_USER | string | - | SSH username |
--ssh-password | SSH_PASSWORD | string | - | SSH password |
--ssh-key | SSH_KEY | string | - | Path to SSH private key |
--ssh-passphrase | SSH_PASSPHRASE | string | - | SSH key passphrase |
*Required unless using
--demo or --config