Skip to main content

SQL Database

Query databases directly from your agent. Supports SQLite, PostgreSQL, and MySQL with read-only safety mode.
Requires the appropriate database driver as a peer dependency: better-sqlite3, pg, or mysql2.

Quick Start


Config

'sqlite' | 'postgres' | 'mysql'
required
Database dialect.
string
required
Connection string (for postgres/mysql) or file path (for sqlite).
boolean
default:"true"
Restrict to read-only queries (SELECT, SHOW, DESCRIBE, EXPLAIN, PRAGMA, WITH).
number
default:"100"
Max rows to return per query.

Tools


Peer Dependencies

Install the driver for your database:

Security

The SQL toolkit includes built-in protections:
  • Read-only mode (default): Only SELECT, SHOW, DESCRIBE, EXPLAIN, PRAGMA, and WITH queries are permitted.
  • Parameterized queries: Schema introspection (sql_describe) uses parameterized queries ($1 bind parameters) for PostgreSQL to prevent SQL injection.
  • Table name validation: Table names are validated against ^[a-zA-Z_]\w*$ to reject injection attempts.
Read-only mode is enabled by default. Set readOnly: false only if your agent needs to write data.
See the Security page for a full overview of security hardening across Agentium.