Skip to main content
Use the pg_psql tool to run SQL against a Heroku Postgres follower database. As noted in Working with MCP, database tools work only with followers so your production data remains read-only for agents. Results are returned as JSON, which makes it easy to answer analytical questions or power dashboards.

Requirements

  • target_app_name pointing to the Heroku app with the database
  • Appropriate database credentials configured via config vars
  • A follower database provisioned via heroku pg:copy or heroku addons:create`

Example prompt

Query the database for the top 5 customers by annual recurring revenue.

Tips

  • Use parameterized queries to avoid SQL injection.
  • Limit result sets to keep responses manageable.
  • Combine with the Doc reader to explain table schemas before querying.
  • For complex data pipelines, consider deploying the pg_psql MCP template so you can extend behavior beyond the built-in tool.