Skip to main content
Read-only mode restricts the execute_sql tool to statements that read data. It is a guardrail against accidental and agent-initiated writes, not a permission boundary: what a connection can ultimately do is decided by the database account DBHub connects with.

Enabling

Set readonly = true on the execute_sql tool of a source:
The MCP Bundle and the Claude Code Plugin ship with this already set. readonly is a per-tool setting:

How It Is Enforced

A statement goes through two layers. 1. Keyword classifier. Before anything reaches the database, DBHub strips comments and string literals and checks each statement against an allow-list of read-only keywords for the dialect: SELECT, WITH and EXPLAIN everywhere, plus SHOW (PostgreSQL, MySQL, MariaDB), DESCRIBE (MySQL, MariaDB) and PRAGMA (SQLite). When several statements are sent together, every one of them must pass. 2. Engine-level backstop. The statement then runs under the database’s own read-only mechanism, so the database rejects or discards a write even if the classifier is evaded: On SQL Server, statements that would end the transaction or run outside it are rejected before it opens: COMMIT/ROLLBACK, dynamic SQL such as EXEC, and pass-through data sources such as OPENQUERY.
Engine-level enforcement was added in 0.22.6. Earlier versions relied on the keyword classifier alone.

What It Does Not Cover

Read-only mode prevents data modification (DML/DDL). It cannot constrain everything a privileged database role can do through functions. Every supported engine has functions or packages that a plain SELECT can call to read or write server files, open network connections or reach other servers — for example lo_export and dblink on PostgreSQL, LOAD_FILE on MySQL/MariaDB, OPENROWSET on SQL Server, and UTL_HTTP on Oracle. These are gated by database privileges, not by transaction mode, so a read-only transaction does not stop them. DBHub rejects a per-dialect list of well-known ones by name, but that matching is best-effort and not exhaustive (#377).
For untrusted or agent-driven environments, always connect DBHub with a least-privilege, read-only database user scoped to the data it needs. Do not point a read-only tool at an admin/superuser DSN and rely on read-only mode alone.