Quick Start
- Copy the example configuration:
-
Edit
dbhub.tomlwith your database connections -
Start DBHub (automatically detects
./dbhub.toml):
Configuration Structure
A TOML configuration file has two main sections:[[sources]]- Database connection definitions (required, can have multiple)[[tools]]- Tool configuration and custom tools (optional)
Sources Configuration
Each[[sources]] entry defines a database connection:
Unique identifier for this database source.Used in tool names (
execute_sql_{id}) and the source_id parameter when calling tools.Human-readable description of this data source. Helps document your configuration.
Database connection string.Format:
protocol://[user[:password]@]host[:port]/database[?options]Alternatively, use individual connection parameters (see below).Connection Methods
Method 1: DSN Connection String (recommended)Database type.Options:
postgres, mysql, mariadb, sqlserver, sqliteRequired when not using dsn.Database server hostname or IP address.
Database server port. Defaults to standard port for database type.Defaults: PostgreSQL (5432), MySQL/MariaDB (3306), SQL Server (1433)
Database name. For SQLite, this is the file path.
Database username.
Database password. Can contain special characters.
Database-Specific Options
PostgreSQL Options
PostgreSQL Options
Comma-separated list of schemas for PostgreSQL search path.Example:
"myschema,public"The first schema is the default for schema discovery operations.SQL Server Options
SQL Server Options
SQL Server named instance name.Example:
"SQLEXPRESS"Authentication method.Options:
ntlm- Windows/NTLM authentication (requiresdomain)azure-active-directory-access-token- Azure AD authentication
Windows domain for NTLM authentication.Required when
authentication = "ntlm".SQLite Options
SQLite Options
SQLite only requires
type and database (file path):Connection Options
Connection timeout in seconds.
Query execution timeout in seconds.Supported by PostgreSQL, MySQL, MariaDB, and SQL Server. Not supported by SQLite.
Defer connection until first query.Useful for remote databases or connections through SSH tunnels to avoid startup overhead.
SSL encryption mode.Options:
disable- No SSL encryptionrequire- SSL encryption without certificate verification
SSH Tunnel Configuration
Connect to databases through SSH bastion hosts:SSH server hostname or IP address.
SSH server port.
SSH username.
SSH password authentication. Use either this or
ssh_key.Path to SSH private key file. Supports
~/ expansion.Passphrase for encrypted SSH private key.
Comma-separated list of jump hosts for multi-hop connections.Format:
[user@]host[:port],[user@]host[:port],...Note: All hosts use the same SSH key/password specified in ssh_key or ssh_password.Seconds between SSH keepalive packets. Set to 0 to disable.
Maximum missed keepalive responses before disconnecting.
Tools Configuration
The[[tools]] section customizes tool behavior per database and defines custom SQL tools.
Built-in Tool Configuration
DBHub provides two built-in tools for each source:execute_sql- Execute arbitrary SQL queriessearch_objects- Search and list database objects
execute_sql behavior per source:
Tool name. Use
"execute_sql" to configure the built-in SQL execution tool.Source ID this tool applies to. Must match a
[[sources]] entry.Restrict to read-only SQL operations.Only allows:
SELECT, SHOW, DESCRIBE, EXPLAIN, WITH (CTEs)Only valid for execute_sql and custom tools.Limit maximum rows returned from SELECT queries.Only valid for
execute_sql and custom tools.Without a
[[tools]] entry, execute_sql has no restrictions - it can execute any SQL including INSERT, UPDATE, DELETE, DROP.Custom SQL Tools
Define reusable, parameterized SQL operations as MCP tools:Custom tool name. Must not be
execute_sql or search_objects.Will be exposed as {name}_{source_id} in the MCP tool list.Tool description shown to AI models and in the workbench.
SQL query or statement to execute.Use parameterized placeholders:
- PostgreSQL:
$1,$2,$3 - MySQL/MariaDB:
?,?,? - SQL Server:
@p1,@p2,@p3 - SQLite:
?,?,?
Tool parameter definitions (optional). See below for structure.
Parameter Configuration
Each parameter in theparameters array:
Parameter name.
Parameter data type.Options:
string, integer, float, boolean, arrayParameter description.
Whether parameter is required.
Default value (makes parameter optional).
Enum constraint - list of allowed values.
Custom Tool Examples
Using Multi-Database Configuration
When you configure multiple sources, tools are named with the source ID suffix:execute_sql_prod_pgsearch_objects_prod_pgexecute_sql_analyticssearch_objects_analytics
source_id parameter with default tool names:
The first source in your TOML file is the default database when
source_id is not specified.Complete Configuration Example
Validation and Error Handling
DBHub validates your TOML configuration on startup:- Duplicate source IDs - Each source must have a unique
id - Missing required fields - Sources need
idand connection info - Invalid database types - Only supported types allowed
- Tool/source references - Tools must reference existing sources
- Duplicate tools - Can’t define same tool+source combination twice
- Invalid SSL modes - Only
disableandrequiresupported - SQL Server auth - Validates NTLM requires domain, etc.
- Password redaction - Automatically hides passwords in logs
Best Practices
- Use descriptive IDs - Choose clear source IDs like
prod_pg,staging_mysql,analytics - Document with descriptions - Add
descriptionfields to help team members understand each source - Enable read-only for production - Protect production databases with
readonly = true - Set reasonable timeouts - Configure
connection_timeoutandquery_timeoutfor remote databases - Use lazy connections - Set
lazy = truefor remote databases to speed up startup - Secure your TOML file - Add
dbhub.tomlto.gitignoreif it contains credentials - Use SSH tunnels for production - Always connect to production databases through bastion hosts
- Test with demo mode - Use
--demoflag to test configuration changes safely
Migration from Environment Variables
If you’re currently using environment variables or command-line flags:Next Steps
execute_sql Tool
Learn about SQL execution and readonly mode
Debugging
Troubleshoot configuration and connection issues