Overview
TOML configuration enables:- Multi-database support: Connect to multiple databases from a single DBHub instance
- Per-source settings: Configure timeouts, SSL, SSH tunnels, and lazy connections individually per database
- Per-tool settings: Apply different restrictions (readonly, max_rows) per tool
- Custom tools: Define reusable, parameterized SQL operations as MCP tools
- Environment variable interpolation: Use
${VAR}syntax to avoid hardcoding credentials - Hot reload: Automatically detect config changes and reload connections without restarting
Hot Reload
When using TOML configuration, DBHub automatically watchesdbhub.toml for changes and reloads database connections without requiring a server restart.
How it works:
- DBHub detects file changes and waits 500ms (debounce) to handle editors that write in multiple steps
- The new configuration is parsed and validated — if invalid, existing connections are preserved
- All database connections are disconnected and reconnected with the new configuration
- If reconnection fails, DBHub automatically rolls back to the previous working configuration
STDIO transport limitation: In STDIO mode (the default for Claude Desktop, Cursor, etc.), hot reload updates the underlying database connections and tool settings, but clients won’t see newly added or removed tools until a full server restart. This is because STDIO clients discover tools once at startup.HTTP transport (
--transport http) creates a fresh server per request, so all changes — including added/removed tools — take effect immediately.Environment Variable Interpolation
Use${VAR_NAME} syntax to reference environment variables in any string value. Variables are resolved from the process environment at config load time.
This lets teams share a single dbhub.toml without hardcoding credentials:
dbhub.toml
Unresolved variables (where the environment variable is not set) are left as the literal
${VAR_NAME} string. No error is thrown for missing variables.Configuration Structure
A TOML configuration file has two main sections:[[sources]]- Database connection definitions[[tools]]- Tool configuration (execution settings, custom tools)
dbhub.toml in your project directory:
dbhub.toml
Source Options
Sources define database connections. Each source represents a database that DBHub can connect to.id
Required. Unique identifier for this data source. Used for routing tool calls and in tool names.
description
Human-readable description of this data source. Helps AI models understand the purpose and contents of each database when multiple sources are configured.
dsn
Required. Database connection string. Same format as command-line
--dsn.- Using DSN
- Individual Parameters
connection_timeout
Connection timeout in seconds. The maximum time to wait when establishing a database connection.Supported databases: PostgreSQL, MySQL, MariaDB, SQL Server (not applicable to SQLite).
This option is only available via TOML. There is no CLI flag for connection timeout.
query_timeout
Query timeout in seconds. The maximum time to wait for a query to complete before timing out.Supported databases: PostgreSQL, MySQL, MariaDB, SQL Server (not applicable to SQLite).
This option is only available via TOML. There is no CLI flag for query timeout.
lazy
Defer database connection until the first query. When enabled, the connection is not established at server startup but instead when a tool first accesses this source.This is useful for remote databases (e.g., RDS, Cloud SQL) where you want to avoid unnecessary connection overhead if the database may not be queried during a session.Startup behavior:
- Without
lazy: Connection established immediately, errors shown at startup - With
lazy = true: Source registered but not connected, connection errors appear on first query
When a lazy source is accessed for the first time, there will be a brief delay as the connection is established. Connection errors will appear in tool responses rather than at startup.
sslmode
SSL/TLS mode for database connections.Options:
disable- No SSL/TLS encryption. Data is transmitted in plaintext.require- SSL/TLS encryption enabled, but server certificate is not verified.
instanceName
SQL Server named instance. Use when connecting to a specific SQL Server instance (e.g., SQLEXPRESS, ENV1).SQL Server only.
authentication
SQL Server authentication method. SQL Server only.Options:
ntlm- Windows/NTLM authentication. Requiresdomainparameter.azure-active-directory-access-token- Azure AD authentication. Token is fetched automatically using Azure SDK.
domain
Windows domain for NTLM authentication. Required when
authentication=ntlm. SQL Server only.search_path
Comma-separated list of PostgreSQL schema names to set as the session Without
search_path. The first schema in the list becomes the default schema for all discovery methods (getTables, getTableSchema, etc.).PostgreSQL only.search_path, DBHub defaults to the public schema for all schema discovery operations.This option is only available via TOML. It is not supported as a DSN query parameter.
SSH Tunnel Options
SSH tunnel configuration for connecting to databases through bastion/jump hosts. Available fields: See Command-Line Options - SSH Tunnel for complete documentation and examples.
ssh_host, ssh_port, ssh_user, ssh_password, ssh_key, ssh_passphrase, ssh_proxy_jump.Tool Options
Tools define MCP tools (likeexecute_sql) with specific execution settings. Tool options control how tools execute queries, not what databases they connect to.
name
Required. Tool name. Currently, the primary tool is
execute_sql.source
Required. The source ID this tool should use. Must match an
id from the [[sources]] section.readonly
Restrict SQL execution to read-only operations (SELECT, SHOW, DESCRIBE, EXPLAIN, PRAGMA). Write operations like INSERT, UPDATE, DELETE are blocked.See Execute SQL documentation for more details.
This is a tool-level setting, not a source-level setting. Configure it in the
[[tools]] section, not in [[sources]].max_rows
Maximum number of rows to return from SELECT queries. Queries returning more rows will be truncated.See Execute SQL documentation for more details.
This is a tool-level setting, not a source-level setting. Configure it in the
[[tools]] section, not in [[sources]].statement
Optional predefined SQL statement for custom tools. Enables creating reusable, parameterized database operations that are automatically registered as MCP tools.See Custom Tools documentation for examples and patterns.
description
Required for custom tools. Human-readable description of the tool’s purpose. Helps AI models understand when and how to use the tool.
parameters
Parameter definitions for custom tools. Each parameter defines a typed input that will be validated before execution.Parameter Fields:
Parameter Placeholders by Database:
Basic Parameter:Optional Parameter with Default:Constrained Parameter (Enum):Optional Parameter (Nullable):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Parameter name (must match SQL placeholder order) |
type | string | ✅ | Data type: string, integer, float, boolean, array |
description | string | ✅ | Description of the parameter’s purpose |
required | boolean | ❌ | Whether the parameter is required (default: true) |
default | any | ❌ | Default value if parameter not provided |
allowed_values | array | ❌ | List of allowed values (creates enum validation) |
| Database | Syntax | Example |
|---|---|---|
| PostgreSQL | $1, $2, $3 | WHERE id = $1 AND status = $2 |
| MySQL | ?, ?, ? | WHERE id = ? AND status = ? |
| MariaDB | ?, ?, ? | WHERE id = ? AND status = ? |
| SQLite | ?, ?, ? | WHERE id = ? AND status = ? |
| SQL Server | @p1, @p2, @p3 | WHERE id = @p1 AND status = @p2 |
Complete Example
dbhub.toml
Quick Reference
Source Options
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Unique source identifier |
description | string | ❌ | Human-readable description of the data source |
dsn | string | ✅ | Database connection string |
lazy | boolean | ❌ | Defer connection until first query (default: false) |
connection_timeout | number | ❌ | Connection timeout (seconds) |
query_timeout | number | ❌ | Query timeout (seconds) |
sslmode | string | ❌ | SSL mode: disable, require |
instanceName | string | ❌ | SQL Server named instance |
authentication | string | ❌ | SQL Server auth method |
domain | string | ❌ | Windows domain (NTLM) |
search_path | string | ❌ | PostgreSQL schema search path (comma-separated) |
ssh_host | string | ❌ | SSH server hostname |
ssh_port | number | ❌ | SSH server port (default: 22) |
ssh_user | string | ❌ | SSH username |
ssh_password | string | ❌ | SSH password |
ssh_key | string | ❌ | SSH private key path |
ssh_passphrase | string | ❌ | SSH key passphrase |
ssh_proxy_jump | string | ❌ | ProxyJump hosts |
Tool Options
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Tool name (e.g., execute_sql) |
source | string | ✅ | Source ID to use |
description | string | ✅* | Tool description (*required for custom tools) |
statement | string | ❌ | Predefined SQL for custom tools |
parameters | array | ❌ | Parameter definitions for custom tools |
readonly | boolean | ❌ | Read-only mode (default: false) |
max_rows | number | ❌ | Max rows limit (default: unlimited) |