Features
- Single statements: Execute a single SQL query or command
- Multiple statements: Separate multiple statements with semicolons (
;) - Transactions: Wrap operations in
BEGIN/COMMITblocks for atomic execution - Read-only mode: Configure a tool with
readonly = trueto restrict execution to read-only operations, enforced by both a keyword classifier and the database’s own read-only mode - Row limiting: Configure
max_rowsper tool via TOML[[tools]]to limit SELECT query results
Single Query
Execute a single SELECT, INSERT, UPDATE, or DELETE statement.Multiple Statements
Execute multiple SQL statements in sequence by separating them with semicolons.Each statement is executed sequentially. If one statement fails, subsequent statements may not be executed depending on the database error handling.
Transactions
Wrap multiple operations in a transaction to ensure atomicity. UseBEGIN/COMMIT for successful transactions or ROLLBACK to undo changes.
DDL Operations
Create, alter, or drop database objects.Read-Only Mode
Restrict SQL execution to safe, read-only operations by configuring theexecute_sql tool with readonly = true:
SELECT, WITH and EXPLAIN everywhere, plus a few read-only statements specific to each database), and is then executed under the database’s own read-only mechanism where the engine has one. See Read-Only Mode for how it is enforced on each database and what it does not cover.
Row Limiting
Limit the number of rows returned from SELECT queries to prevent accidentally retrieving too much data:- Only applied to SELECT statements, not INSERT/UPDATE/DELETE
- If your query already has a
LIMITorTOPclause, DBHub uses the smaller value - Can be configured per-tool in TOML configuration
- When the cap actually cuts off rows, the statement’s result carries
"truncated": truealongsidecount, so a capped result is distinguishable from a table that genuinely has exactlymax_rowsrows (detection is exact — DBHub fetches one probe row past the cap; the flag is omitted for complete results). RunCOUNT(*)to get the true total when you see it.
Response Format
The result is a JSON object. Each statement in the call gets its own entry instatements, in order — a single query is a statements array of length one:
countis the number of rows returned, or the number of rows affected for a write.truncated: trueappears on a statement only whenmax_rowscut its rows off (see Row Limiting).messagesappears next tostatementswhen the database sent informational messages (SQL ServerPRINToutput, for example, or the rows and bytes a ClickHouse statement read).- Columns that share a name within one result are suffixed
_1,_2, … so no value is lost.
success: false:
Selective Tool Exposure
Control which tools are available for each database source. By default, bothexecute_sql and search_objects are enabled. You can:
- Disable built-in tools entirely
- Configure specific tools with custom settings
- Expose only custom tools for restricted access
If no
[[tools]] entries are defined for a source, both execute_sql and search_objects are enabled by default for backward compatibility.See Also
- search_objects - Database schema exploration tool
- explain_sql - Query execution plan tool (opt-in)
- health_check - Connection pool and buffer cache metrics tool (opt-in)
- Custom Tools - Reusable, parameterized SQL operations