tools icon indicating copy to clipboard operation
tools copied to clipboard

[FEATURE] query_postgres for Executing SQL Queries on PostgreSQL

Open Sagart-cactus opened this issue 1 year ago • 1 comments

Problem Statement

This feature request proposes the addition of a new tool named query_postgres to the strands-tools suite. The tool allows agents to securely connect to a PostgreSQL database and run parameterized SQL queries, returning structured results for further use in workflows.

Proposed Solution

Proposed Functionality The query_postgres tool supports:

  • Connecting to a PostgreSQL database using provided credentials.
  • Executing user-defined, parameterized SQL queries (e.g., SELECT, INSERT, UPDATE).
  • Returning structured query results to the agent in JSON format.
  • Optional support for environment-variable-based configuration for secure handling of credentials.

Have taken the liberty to create the PR: https://github.com/strands-agents/tools/pull/135

Use Case

Agents often require access to relational data for decision-making or automation tasks. Currently, there is no built-in tool in strands-tools that enables querying a PostgreSQL database. Adding query_postgres fills this gap and aligns with the modular design of the toolkit

Alternatives Solutions

No response

Additional Context

Open to code review and any suggestions on improving the PR.

Sagart-cactus avatar Jul 18 '25 02:07 Sagart-cactus

Hi @Sagart-cactus Thank you for raising this request, our tool repo is community driven, we would like to recommend you follow this guideline to create your own package https://github.com/strands-agents/docs/blob/main/docs/community/community-packages.md

JackYPCOnline avatar Dec 04 '25 20:12 JackYPCOnline