Graphrt

PostgreSQL

Parameterised queries in database-enforced read-only transactions with timeouts and row/byte caps, writes and DDL (nodes, or agents with an opt-in), tables, columns and plans

Stable v0.1.0 Node.js 5 actions
Use in Graphrt Desktop

About

A Graphrt plugin that runs parameterised SQL on PostgreSQL with the pg driver. Agents get read-only access by default: query runs inside a READ ONLY transaction that is always rolled back, so the database itself refuses writes.

What it can do

  • query: one parameterised statement ($1, $2, ...) in a read-only transaction. Returns rows (objects), fields (name and type), row_count and truncated.
  • execute: one INSERT/UPDATE/DELETE/DDL statement, committed. Returns command, affected_rows and any RETURNING rows. Workflow nodes only, unless POSTGRES_TOOL_ALLOW_WRITES=1.
  • explain: EXPLAIN (text or JSON, optionally ANALYZE) in a read-only transaction.
  • list_tables and describe_table: tables and views, columns (type, nullable, default, comment), primary key, indexes and foreign keys.
  • Every operation is a node postgres.<operation> and an agent tool. The full reference is in OPERATIONS.md.

Actions

Each action is a step you can add to a workflow. Agents can also use most of them as tools.

  • Run a read-only query postgres.query
  • Run a write or DDL statement postgres.execute
  • Explain a query plan postgres.explain
  • List tables postgres.list_tables
  • Describe a table postgres.describe_table

Settings

Graphrt starts plugins with a clean environment. Only these values reach the plugin, and secrets stay out of logs.

  • POSTGRES_URL (none)
    Connection URL, e.g. postgres://app:secret@db.example.com:5432/shop?sslmode=verify-full. Percent-encode special characters in the password.
  • POSTGRES_HOST Port 5432
    Used when POSTGRES_URL is unset. POSTGRES_HOST may also be a Unix socket directory.
  • POSTGRES_SSLMODE Disable
    With the separate parts: disable, require (TLS without certificate checks) or verify-full. With a URL, put sslmode in the URL.
  • POSTGRES_STATEMENT_TIMEOUT_MS 30000
    Default statement timeout (100 to 600000). Nodes may pass any statement_timeout_ms, for agent tool calls this value is also the ceiling.
  • POSTGRES_CONNECT_TIMEOUT_MS 10000
    Connect timeout
  • POSTGRES_MAX_RESULT_BYTES 1000000
    Most JSON bytes of returned rows per call (1000 to 8000000)
  • POSTGRES_POOL_MAX 4
    Connections per pool
  • POSTGRES_TOOL_ALLOW_WRITES (off)
    1 lets agents call execute. Leave it off unless the role itself is limited.
  • POSTGRES_ALLOW_SUPERUSER (off)
    1 lets agent tool calls run on a superuser connection (refused by default, see Safety)
  • POSTGRES_PORT
  • POSTGRES_USER
  • POSTGRES_PASSWORD
  • POSTGRES_DATABASE

How to use it

In Graphrt Desktop

  1. Open Plugins and search for PostgreSQL.
  2. Click Install and approve it.
  3. Follow the setup steps on the plugin's page, then paste the settings it needs.
  4. Describe a job that needs it, and the builder adds the steps.
Plugins in Graphrt Desktop

With the CLI

terminal
$ graphrt plugin install postgres
workflow.yaml
- id: orders
  type: postgres.query
  sql: "SELECT id, total, created_at FROM orders WHERE customer_id = $1 AND created_at >= $2 ORDER BY created_at DESC"
  params: ["{{#start.customer_id#}}", "2026-11-01"]
  max_rows: 50
- id: mark
  type: postgres.execute
  sql: "UPDATE orders SET status = $1 WHERE id = $2 RETURNING id, status"
  params: ["shipped", "{{#orders.data.rows.0.id#}}"]
Plugins in the docs