Connect your agents to external databases with granular permissions, query limits, and full audit logging.
For everyone: The Database Access page lets you connect your AI agents to your databases (PostgreSQL, MySQL, MongoDB, Redis, and more). Instead of giving agents raw database credentials, you create managed connections with specific permissions — like giving an agent read-only access to your products table but blocking access to the users_secrets table. Every query the agent runs is logged.
For technical users: This module manages database connection pooling, per-agent RBAC with operation-level granularity (read/write/delete/schema/execute), row-level query limits, table-level blocklists, optional human-in-the-loop approval for mutations, and a full SQL audit log. Credentials are encrypted in the Vault. The engine exposes /database/connections, /database/agents/:id/connections, and /database/audit endpoints.
| Tab | Purpose |
|---|---|
| Connections | Manage database connections — add, test, edit, delete, and grant access. |
| Agent Access | View which agents have access to which databases, with what permissions. Revoke access. |
| Audit Log | Full query log with filters for agent, operation, status, and text search. |
| Status | Meaning |
|---|---|
| active | Connection is healthy and available. |
| inactive | Connection is configured but not yet tested/activated. |
| error | Last connection attempt failed. Check error message. |
Displays all database connections as cards showing type, name, host/port/database, status, and last error (if any).
postgresql://user:pass@host:5432/db) or fill in individual fields — whichever is easier. The connection string takes precedence if provided.
| Database | Value |
|---|---|
| PostgreSQL | postgresql |
| MySQL | mysql |
| MariaDB | mariadb |
| Microsoft SQL Server | mssql |
| Oracle | oracle |
| SQLite | sqlite |
| Database | Value |
|---|---|
| Supabase | supabase |
| Neon | neon |
| PlanetScale | planetscale |
| CockroachDB | cockroachdb |
| Turso / LibSQL | turso |
| Database | Value |
|---|---|
| MongoDB | mongodb |
| Redis | redis |
| Upstash Redis | upstash |
| AWS DynamoDB | dynamodb |
Shows a card for each agent that has database access. Each card lists:
When granting an agent access to a database, you select which operations they can perform:
| Permission | Operations | Color | Risk Level |
|---|---|---|---|
| Read | SELECT queries | Green | Low |
| Write | INSERT / UPDATE | Orange | Medium |
| Delete | DELETE rows | Red | High |
| Schema | DDL operations (CREATE TABLE, ALTER, DROP) | Blue | Very High |
| Execute | Stored procedures and functions | Gray | Varies |
Each agent access grant includes configurable safety limits:
| Limit | Default | Description |
|---|---|---|
| Max Read Rows | 10,000 | Maximum rows returned by SELECT queries |
| Max Write Rows | 1,000 | Maximum rows affected by INSERT/UPDATE |
| Max Delete Rows | 100 | Maximum rows affected by DELETE |
users_secrets, payment_tokens).Every database query executed by an agent is logged with full details:
| Column | Description |
|---|---|
| Time | When the query was executed |
| Agent | Which agent ran the query |
| Database | Which connection was used |
| Operation | read, write, delete, schema, or execute |
| Query | The SQL query (truncated in table, full in detail view) |
| Rows | Number of rows affected |
| Latency | Execution time in milliseconds |
| Status | OK or FAIL |
Click any row to expand and see:
| Method | Endpoint | Description |
|---|---|---|
| GET | /database/connections | List all connections |
| POST | /database/connections | Create a new connection |
| PUT | /database/connections/:id | Update a connection |
| DELETE | /database/connections/:id | Delete a connection (and all grants) |
| POST | /database/connections/:id/test | Test an existing connection |
| POST | /database/connections/test | Test connection params before saving |
| POST | /database/connections/:id/agents | Grant agent access to a connection |
| DELETE | /database/connections/:id/agents/:agentId | Revoke agent access |
| GET | /database/agents/:id/connections | List connections an agent can access |
| GET | /database/audit?limit= | Query audit log |
POST /database/connections/:id/agents
{
"agentId": "agent-123",
"permissions": ["read", "write"],
"queryLimits": {
"maxRowsRead": 10000,
"maxRowsWrite": 1000,
"maxRowsDelete": 100
},
"schemaAccess": {
"blockedTables": ["users_secrets", "payment_tokens"]
},
"logAllQueries": true,
"requireApproval": false
}
// Using connection string
POST /database/connections
{
"type": "postgresql",
"name": "Production DB",
"connectionString": "postgresql://user:pass@host:5432/mydb",
"description": "Main production database"
}
// Using individual fields
POST /database/connections
{
"type": "mysql",
"name": "Analytics DB",
"host": "analytics.example.com",
"port": 3306,
"database": "analytics",
"username": "reader",
"password": "...",
"ssl": true,
"description": "Read-only analytics database"
}
Verify: host/port are correct, database exists, credentials are valid, firewall allows the connection, and SSL setting matches the server. Check the error message for details — common issues are "ECONNREFUSED" (wrong host/port) and "authentication failed."
Check the Agent Access tab to verify the agent has been granted access with the correct permissions. Ensure the operation type (read/write/delete) matches the agent's granted permissions.
The agent's query returned more rows than the configured limit. Either increase the limit in the grant settings or have the agent add a LIMIT clause to their queries.
The agent tried to access a table in the blocked list. If this is intentional, remove the table from the blockedTables list in the grant settings.
Click the failed entry to expand details and see the error message. Common causes: permission denied (operation not granted), syntax errors, table not found, or connection timeout.
The last connection attempt failed. Click "Test" to retry and see the specific error. Common fixes: restart the database server, check network connectivity, or update credentials if they've been rotated.