The Postgres provider lets agents inspect database metadata, run bounded read-only queries, export bounded result sets, and, when explicitly enabled, run guarded writes, admin statements, and controlled row imports without ever receiving Postgres credentials. The provider is an optional binary. The mainDocumentation Index
Fetch the complete documentation index at: https://aivault.moldable.sh/docs/llms.txt
Use this file to discover all available pages before exploring further.
aivault binary does not link the Rust Postgres
client dependency.
Install and enable
If you installed aivault from the official release installer, the Postgres provider binary is bundled beside the CLI. Install and enable it:Store credentials
Store the Postgres connection details as a JSON secret. Use a workspace scope when the database belongs to a specific Moldable workspace or project.--host value is a credential allowlist. It can be a hostname or host:port. Runtime
connection attempts fail closed if the secret points anywhere else.
--max-policy-mode is a per-credential ceiling. It accepts read-only, write, or admin.
Omitting it defaults to read-only. A request cannot raise itself above this credential ceiling.
Secret JSON formats
Connection URL:disablepreferrequireverify-caverify-full
Capabilities
| Capability | Purpose |
|---|---|
postgres/test-connection | Verify connectivity and return database/user/version metadata |
postgres/list-schemas | List non-system schemas |
postgres/list-tables | List tables, optionally within one schema |
postgres/describe-table | Return columns, nullability, defaults, and primary key flags |
postgres/preview-table | Return bounded rows from a specific table |
postgres/query | Run a bounded read-only SQL query |
postgres/export-query | Return bounded CSV or JSONL for a read-only query |
postgres/export-file | Write a bounded read-only export to an aivault-controlled export root |
postgres/import-rows | Import bounded CSV or JSONL rows from an aivault-controlled import root |
postgres/execute | Run one guarded common write statement |
postgres/admin | Run one guarded admin statement |
Examples
Test the connection:Limits and safety
- Query execution uses
BEGIN READ ONLY. postgres/queryacceptsSELECT,WITH,VALUES,SHOW, and non-ANALYZEEXPLAINstatements only.- Postgres credentials may additionally set
maxPolicyMode; requests above the credential ceiling are rejected before provider execution. Missing credential ceilings default toread-only. postgres/export-queryacceptsSELECT,WITH, andVALUESonly and returns content injsonlorcsvformat. The defaultmaxExportBytesis1048576; maximum is10485760.postgres/export-fileuses the same read-only query/export limits, writes only under the aivault-controlled Postgres export root (<vault>/postgres/exports), and currently supports destinationdefault.postgres/import-rowsrequires explicitpolicyModeofwriteoradmin, an explicit schema/table/column list, and a UTF-8csvorjsonlsource file under the aivault-controlled Postgres import root (<vault>/postgres/imports). The defaultmaxImportBytesis1048576; maximum is10485760. The defaultmaxRowsis1000; maximum is10000.- Imports run inside a single transaction and use provider-internal
COPY FROM STDIN; callers cannot pass rawCOPYSQL or arbitrary source paths. postgres/executerequires explicitpolicyModeofwriteoradmin, and the credentialmaxPolicyModemust allow that mode.postgres/executecurrently allows oneINSERT,UPDATE, orDELETEstatement only.UPDATEandDELETEmust include aWHEREclause.postgres/executerejectsRETURNINGand rolls back when the affected row count exceedsmaxAffectedRows. The defaultmaxAffectedRowsis100; maximum is1000.postgres/adminrequires explicitpolicyMode: "admin".postgres/adminallows one guarded schema, permission, or maintenance statement. It rejects instance-level targets such as databases, roles/users, tablespaces, servers, subscriptions, and publications.- Mutation/admin statements such as
INSERT,UPDATE,DELETE,ALTER,DROP,COPY,VACUUM,CALL, andDOare rejected before execution bypostgres/query. - Raw
COPY, arbitrary source/destination paths, and long-lived transaction/session workflows are not exposed through generic SQL capabilities. File import/export must use the dedicated aivault-controlled roots above. Transaction sessions still need a dedicated session model. EXPLAIN ANALYZEis rejected because it executes the underlying statement.- Multiple statements are rejected.
- Default row limit is
100; maximum is1000. offsetdefaults to0and can be used withlimitfor paging. There is no artificial maximum offset; large offsets are still constrained by the query timeout.- Default timeout is
5000ms; maximum is30000ms. - Read-only invocation and file export are audited as
postgres.invoke;postgres/import-rows,postgres/execute, andpostgres/adminare audited aspostgres.write.
prds/postgres-file-session-capabilities.prd.md.
That workflow requires dedicated session policy before it should be exposed.