What it does

The Postgres SQL tool lets your agents run SQL queries directly on your PostgreSQL database. Perfect for data analysis, reporting, and retrieving specific information from your database.
Requires Postgres Integration: You need to set up a Postgres integration before agents can use this tool.

Key features

  • Execute any SQL query (SELECT, INSERT, UPDATE, DELETE)
  • Automatic 100-row limit to prevent performance issues
  • Clean, structured results that agents can easily parse
  • Built-in error handling for common SQL issues

Parameters

ParameterTypeRequiredDescription
sql_querystringYesThe SQL query to execute
row_limitintegerNoMax rows to return (default: 100, max: 1000)

Common use cases

Data analysis

SELECT 
  DATE_TRUNC('month', order_date) as month,
  COUNT(*) as total_orders,
  SUM(total_amount) as revenue
FROM orders 
WHERE order_date >= '2024-01-01'
GROUP BY month
ORDER BY month DESC;

User lookups

SELECT user_id, email, last_login, account_status
FROM users 
WHERE email = 'user@example.com';

Performance monitoring

SELECT COUNT(*) as active_sessions
FROM pg_stat_activity 
WHERE state = 'active';

Security best practices

  • Use read-only database users when possible
  • Avoid querying sensitive data (passwords, API keys, PII)
  • Use WHERE clauses to limit data exposure
  • Monitor agent queries regularly

Troubleshooting

“Could not connect to database”
  • Check that your Postgres integration is configured and connected
  • Verify database server is running and accessible
“Permission denied for table”
  • Ensure your database user has SELECT permissions
  • Check that the table exists and is accessible
“Syntax error”
  • Validate your SQL syntax
  • Check table and column names for typos

Tool Metadata

  • Name: postgres_sql
  • Display Name: Postgres SQL
  • Description: Execute a SQL query on Postgres
  • Required Integration: Postgres
  • Row Limit: 100 rows (configurable up to 1,000)