Skip to main content
TOML configuration is the recommended way to configure DBHub for multi-database setups and advanced configurations. It provides more flexibility than command-line options or environment variables.
Load a TOML file with --config:
A TOML file defines its own database sources, so --config and --dsn cannot be combined. Environment variables such as DSN and DB_* remain available to the file through ${VAR} interpolation.

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 watches dbhub.toml for changes and reloads database connections without requiring a server restart. How it works:
  1. DBHub detects file changes and waits 500ms (debounce) to handle editors that write in multiple steps
  2. The new configuration is parsed and validated — if invalid, existing connections are preserved
  3. All database connections are disconnected and reconnected with the new configuration
  4. 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:
  1. [[sources]] - Database connection definitions
  2. [[tools]] - Tool configuration (execution settings, custom tools)
Create dbhub.toml in your project directory, then load it with --config ./dbhub.toml:
dbhub.toml
Start DBHub:

Source Options

Sources define database connections. Each source represents a database that DBHub can connect to.

id

string
required
Required. Unique identifier for this data source. Used for routing tool calls and in tool names.

description

string
Human-readable description of this data source. Helps AI models understand the purpose and contents of each database when multiple sources are configured.

dsn

string
required
Required. Database connection string. Same format as command-line --dsn.
Mixing dsn with individual fields. A dsn already encodes the connection identity (type, host, port, database, user, password). Fields that can also live in the DSN query string — sslmode, sslrootcert, instanceName, authentication, domain — may be set alongside a dsn and are applied when the DSN omits them.If such a field is set to a value that contradicts the DSN (e.g. dsn = "...?sslmode=disable" together with sslmode = "require", or a host/user/database that differs from the DSN), DBHub rejects the configuration at startup rather than silently ignoring the field. Set each value in only one place, or make the two values match.This includes a field the DSN omits entirely: a database alongside a DSN that names none is rejected too, since the field is never injected into the DSN.

connection_timeout

number
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

number
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

boolean
default:"false"
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

string
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.
  • verify-ca - SSL with CA certificate verification (no hostname check). PostgreSQL only.
  • verify-full - SSL with CA certificate and hostname verification. PostgreSQL only.
Supported databases: PostgreSQL, MySQL, MariaDB, SQL Server (not applicable to SQLite). The verify-ca and verify-full modes are only supported for PostgreSQL.
Can also be set via DSN query parameter: ?sslmode=require or ?sslmode=verify-ca&sslrootcert=/path/to/ca.pem

sslrootcert

string
Path to the CA certificate file for SSL certificate verification. Required when using sslmode=verify-ca or sslmode=verify-full.Supports ~/ path expansion.PostgreSQL only.
Can also be set via DSN query parameter: ?sslmode=verify-full&sslrootcert=/path/to/ca.pem

instanceName

string
SQL Server named instance. Use when connecting to a specific SQL Server instance (e.g., SQLEXPRESS, ENV1).SQL Server only.
Can also be set via DSN query parameter: ?instanceName=ENV1

authentication

string
SQL Server authentication method. SQL Server only.Options:
  • ntlm - Windows/NTLM authentication. Requires domain parameter.
  • azure-active-directory-access-token - Azure AD authentication. Token is fetched automatically using Azure SDK.
Can also be set via DSN query parameter: ?authentication=ntlm&domain=CORP

domain

string
Windows domain for NTLM authentication. Required when authentication=ntlm. SQL Server only.

search_path

string
Comma-separated list of PostgreSQL schema names to set as the session search_path. The first schema in the list becomes the default schema for all discovery methods (getTables, getTableSchema, etc.).PostgreSQL only.
Without 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.

timezone

string
Controls how the driver interprets DATETIME values. Accepts "Z" (UTC), "local", or an offset such as "+09:00".MySQL / MariaDB only.
Passed through to the underlying driver’s timezone connection option. DATETIME is timezone-naive, so the driver needs to know which timezone the stored values represent in order to build the correct Date. When unset, the driver defaults to "local" (the host’s timezone), which yields an incorrect instant whenever the host timezone differs from the data’s. Set this to the timezone the DATETIME values are stored in (e.g. "+09:00") so they are converted to the correct UTC instant.
This option is only available via TOML. It is not supported as a DSN query parameter.

charset

string
Sets the connection character set (e.g. "utf8mb4"). On its own, the connection uses that character set’s default collation; combine with collation to pick a specific one.MySQL / MariaDB only.
This option is only available via TOML. It is not supported as a DSN query parameter.

collation

string
Sets the connection collation (e.g. "utf8mb4_0900_ai_ci"), which determines how string literals and comparisons are ordered/compared on the connection (collation_connection). Can be set on its own or alongside charset; a collation already implies its character set, so when both are given the collation is authoritative.MySQL / MariaDB only.
When neither charset nor collation is set, the driver uses its built-in default (mysql2 defaults to utf8mb4_unicode_ci), which may not match your database’s collation. Set this to align the connection collation with your schema (e.g. MySQL 8’s utf8mb4_0900_ai_ci).
This option is only available via TOML. It is not supported as a DSN query parameter.

SSH Tunnel Options

group
SSH tunnel configuration for connecting to databases through bastion/jump hosts. Available fields: ssh_host, ssh_port, ssh_user, ssh_password, ssh_key, ssh_passphrase, ssh_proxy_jump.
ssh_key accepts either a file path or a base64-encoded private key. DBHub automatically detects the format.See Command-Line Options - SSH Tunnel for complete documentation and examples.

Tool Options

Tools define MCP tools (like execute_sql) with specific execution settings. Tool options control how tools execute queries, not what databases they connect to.
Tool options cannot be set via command-line flags. They are only available in TOML configuration in the [[tools]] section.

name

string
required
Required. Tool name. Built-in tools are execute_sql, search_objects, and the opt-in explain_sql (see explain_sql) and health_check (see health_check); any other name defines a custom tool.

source

string
required
Required. The source ID this tool should use. Must match an id from the [[sources]] section.

readonly

boolean
default:"false"
Restrict SQL execution to read-only operations (SELECT, SHOW, DESCRIBE, EXPLAIN, PRAGMA). Write operations like INSERT, UPDATE, DELETE are blocked.
This is a tool-level setting, not a source-level setting. Configure it in the [[tools]] section, not in [[sources]].
See Execute SQL documentation for more details.

max_rows

number
Maximum number of rows to return from SELECT queries. Queries returning more rows will be truncated.
This is a tool-level setting, not a source-level setting. Configure it in the [[tools]] section, not in [[sources]].
See Execute SQL documentation for more details.

statement

string
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

string
Required for custom tools. Human-readable description of the tool’s purpose. Helps AI models understand when and how to use the tool.

parameters

array
Parameter definitions for custom tools. Each parameter defines a typed input that will be validated before execution.Parameter Fields:Parameter Placeholders by Database:
The number of parameters must match the number of placeholders in your SQL statement. Validation occurs at server startup.
Basic Parameter:
Optional Parameter with Default:
Constrained Parameter (Enum):
Optional Parameter (Nullable):
Use optional parameters with SQL COALESCE to create flexible filters:

Complete Example

dbhub.toml

Quick Reference

Source Options

Tool Options