Postgres / SQL
Connects to a PostgreSQL database via pgx. An agent can run read-only SELECT queries, execute write/DDL statements, describe a table's columns, and list tables in a schema.
Add to an agent node's tools array with _node_type: "tool-sql" (alias tool-postgres). See Connector Reference — How connectors are used.
Authentication
| Field | Required | Description |
|---|---|---|
dsn | Yes* | PostgreSQL connection string, e.g. postgres://user:pass@host:5432/db. |
connection_string | Yes* | Fallback for dsn — used only if dsn is empty. |
* One of dsn or connection_string must be set; otherwise the connector returns an error.
{
"name": "postgres",
"_node_type": "tool-sql",
"dsn": "{{ secret.POSTGRES_DSN }}"
}
tool-postgres is accepted as an equivalent _node_type for the same connector.
Tools
sql_query
Run a SELECT query against PostgreSQL and return results as a formatted table.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | SELECT query to run |
max_rows | number | No | Maximum rows to return (default 100, hard cap 500) |
Returns: A tab-separated table: a header row of column names, a separator line, then up to max_rows data rows (each value formatted with %v), followed by a ... (truncated at N rows) line if truncated, and a final N row(s) count line.
sql_execute
Execute a SQL statement (INSERT, UPDATE, DELETE, CREATE, ALTER). Returns rows affected.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
statement | string | Yes | INSERT UPDATE DELETE or DDL statement |
Returns: OK — N rows affected.
sql_describe_table
Describe a table's columns, types, nullability and defaults.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
table | string | Yes | Table name to describe |
schema | string | No | Schema name (default: public) |
Returns: A tab-separated table with header column\ttype\tnullable\tdefault, a separator line, then one row per column (queried from information_schema.columns).
sql_list_tables
List all tables in a PostgreSQL schema.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
schema | string | No | Schema to list (default: public) |
Returns: Tables in <schema>: followed by one line per table, formatted as <name padded to 40 chars> <table_type> (queried from information_schema.tables).