ToolsIntegrations
postgres
Postgres query tool — BYO runner keeps the adapter client-agnostic (`postgres.js`, `pg`, Drizzle, Prisma, Neon).
import { postgres } from '@agentskit/tools'
import postgresJs from 'postgres'
const sql = postgresJs(process.env.DATABASE_URL!)
const runtime = createRuntime({
adapter,
tools: [...postgres({
run: async (query, params) => sql.unsafe(query, params as unknown[]),
})],
})#Sub-tools
| Name | Purpose |
|---|---|
postgresQuery | Execute parameterized SQL, return rows + row-count |
Bundled: postgres(config).
#Config
type PostgresConfig = {
run: (query: string, params: unknown[]) => Promise<PostgresExecuteResult>
readonly?: boolean // block non-SELECT statements
maxRows?: number // cap on result size
}#Example — data analyst agent
import { postgres } from '@agentskit/tools'
import { sqlAnalystSkill } from '@agentskit/skills'
const runtime = createRuntime({
adapter,
skills: [sqlAnalystSkill],
tools: [...postgres({ run, readonly: true, maxRows: 100 })],
})
await runtime.run('How many users signed up last week vs the week before?')#Safety
- Default to
readonly: true. Let the agent read before it ever writes. - For writes, wrap via mandatory sandbox with an allowlist of tables.
- Never pass string-interpolated queries — always use the
paramsarray.
#Related
- Integrations overview
- Issue #447 — read/write split helper.
- sqliteQueryTool — local alternative.
Explore nearby
- PeerIntegrations
20+ ready-made connectors for the services agents actually need. Each follows the same contract — install, config, execute — and ships granular sub-tools alongside a bundled set.
- Peergithub
GitHub REST v3 — search issues, create issues, comment. Pairs with HITL for ship-gating bots.
- PeergithubActions
GitHub Actions — list runs and trigger workflow_dispatch events.