A reusable SQL database tool for Solace Agent Mesh.
Project description
SQL Database Tool Plugin
This plugin for Solace Agent Mesh (SAM) provides a powerful and dynamic tool for executing SQL queries against a database. It allows any agent to be augmented with direct database access.
Unlike the sam-sql-database agent, which provides a complete Natural-Language-to-SQL agent, this plugin provides a tool that can be added to any existing or new agent. This allows you to create multi-faceted agents that can interact directly with databases for specific, targeted tasks.
About Solace Agent Mesh
Solace Agent Mesh (SAM) is an open-source framework for building event-driven, multi-agent AI systems where specialized agents collaborate on complex tasks. It provides a standardized way for agents to communicate, share data, and integrate with external systems while keeping components loosely coupled and production-ready.
SAM helps you:
- Build event-driven multi-agent systems on Solace Event Mesh
- Connect agents, tools, gateways, and services through a common runtime
- Extend projects with installable plugins such as
sam-sql-database-tool
Learn more in the Solace Agent Mesh documentation and the main project repository.
Key Features
- Dynamic Tool Creation: Define custom SQL query tools directly in your agent's YAML configuration. Each tool instance is completely independent.
- Multi-Database Support: Natively supports PostgreSQL, MySQL, MariaDB, MSSQL, and Oracle.
- Dedicated Connections: Each tool instance creates its own dedicated database connection, allowing for fine-grained configuration.
- Flexible Schema Handling:
- Automatic schema detection and summarization for LLM prompting.
- Manual override for providing a detailed schema and a natural language summary.
Installation
To add this tool to a new or existing agent, you must first install it and then manually add the tool configuration to your agent's YAML file:
sam plugin install sam-sql-database-tool
This creates a new component configuration at configs/plugins/<your-component-name-kebab-case>.yaml.
Configuration
To use the tool, add one or more tool_type: python blocks to the tools list in your agent's app_config. Each block will create a new, independent tool instance.
Example Tool Configuration
Here is an example of configuring a tool to query a customer database.
# In your agent's app_config:
tools:
- tool_type: python
component_module: "sam_sql_database_tool.tools"
class_name: "SqlDatabaseTool"
tool_config:
# --- Tool Definition for LLM ---
tool_name: "QueryCustomerDatabase"
tool_description: "Executes a SQL query against the customer database."
# --- Database Connection Configuration ---
connection_string: "${CUSTOMER_DB_CONNECTION_STRING}"
# --- Schema Handling ---
auto_detect_schema: true
# schema_summary_override: "A table named 'customers' with columns 'id' and 'name'."
# max_enum_cardinality: 100
# schema_sample_size: 100
# cache_ttl_seconds: 3600
# --- Connection Pool (optional tuning) ---
# pool_size: 10
# max_overflow: 10
# pool_timeout: 30
# pool_recycle: 1800 # Set below your DB's idle timeout
# pool_pre_ping: true
# --- Engine Settings (optional) ---
# echo: false # Log all SQL statements (development only)
# isolation_level: "READ_COMMITTED"
# connect_args: {} # Extra driver kwargs, e.g. {sslmode: "require"}
tool_config Details
tool_name: (Required) The function name the LLM will use to call the tool.tool_description: (Optional) A clear description for the LLM explaining what the tool does.connection_string: (Required) The full database connection string. It is highly recommended to use a single environment variable for the entire string. Supported formats:- PostgreSQL:
postgresql+psycopg2://user:password@host:port/dbname - MySQL:
mysql+pymysql://user:password@host:port/dbname - MariaDB:
mysql+pymysql://user:password@host:port/dbname - MSSQL (Microsoft ODBC - Recommended):
mssql+pyodbc://user:password@host:port/dbname?driver=ODBC+Driver+18+for+SQL+Server- Official Microsoft driver with full feature support (Azure AD auth, Always Encrypted, etc.).
- Requires ODBC Driver 17 or 18 installed on the host system.
- Driver 18+ enables encryption by default. Control this with the
Encryptparameter:Encrypt=yes/Encrypt=mandatory— encrypt all traffic (default in Driver 18+).Encrypt=no/Encrypt=optional— disable encryption.Encrypt=strict— strict TLS; ignoresTrustServerCertificateand requires a fully valid certificate chain (Driver 18+ only).
- Use
TrustServerCertificate=yesto bypass certificate validation for self-signed certificates (not applicable whenEncrypt=strict). - See the Microsoft docs on ODBC connection string keywords for the full list of supported parameters.
- MSSQL (FreeTDS):
mssql+pyodbc://user:password@host:port/dbname?driver=FreeTDS- Open-source driver with simpler installation:
sudo apt-get install freetds-dev freetds-bin tdsodbc && sudo odbcinst -i -d -f /usr/share/tdsodbc/odbcinst.ini - Works well for standard SQL operations.
- Open-source driver with simpler installation:
- Oracle:
oracle+oracledb://user:password@host:port/?service_name=SERVICE_NAME- Uses the
oracledbdriver in thin mode (no Oracle Instant Client required). - Replace
SERVICE_NAMEwith your Oracle service name (e.g.,XEPDB1,ORCL).
- Uses the
- PostgreSQL:
auto_detect_schema: (Optional, default:true) Iftrue, the plugin attempts to automatically detect the database schema. Iffalse, you must provideschema_summary_override.schema_summary_override: (Required ifauto_detect_schemaisfalse) A concise natural language summary of the schema, suitable for direct inclusion in an LLM prompt.max_enum_cardinality: (Optional, default:100) Maximum number of distinct values to consider a column as an enum. Increase for columns like countries (190+), decrease for faster init times.schema_sample_size: (Optional, default:100) Number of rows to sample per table for schema detection. Increase for better accuracy on sparse data, decrease for faster init times.cache_ttl_seconds: (Optional, default:3600) Time-to-live for schema cache in seconds. After this duration, the schema will be re-detected on the next query. Set to0to disable caching.
Connection Pool Settings
pool_size: (Optional, default:10) Number of persistent connections to maintain in the pool. Increase for high-concurrency workloads; decrease to reduce resource usage on low-traffic deployments.max_overflow: (Optional, default:10) Maximum number of additional temporary connections allowed beyondpool_sizeduring traffic spikes. The total connection limit ispool_size + max_overflow.pool_timeout: (Optional, default:30) Seconds to wait for a free connection from the pool before raising aTimeoutError. Increase if you frequently hit timeouts under load.pool_recycle: (Optional, default:1800) Recycle connections after this many seconds to prevent "lost connection" errors. Set this value below your database server's idle connection timeout. Use-1to disable recycling.pool_pre_ping: (Optional, default:true) Test each connection for liveness before use. Keeps the pool healthy after network interruptions. Disable only to reduce per-query latency on very reliable networks.
Engine Settings
echo: (Optional, default:false) Log all SQL statements to the Python logger (sqlalchemy.engine). Enable for development and troubleshooting only — do not use in production.isolation_level: (Optional) Set the transaction isolation level for all connections. Accepted values depend on the database dialect — common values areREAD_COMMITTED,REPEATABLE_READ,SERIALIZABLE, andAUTOCOMMIT. Omit to use the database's default.connect_args: (Optional, default:{}) A dictionary of extra keyword arguments passed directly to the database driver'sconnect()call. Use this for driver-specific options such as SSL certificates, connection timeouts, or character set settings. Example for PostgreSQL:connect_args: {sslmode: "require"}.
Tool Parameters
The generated tool accepts a single parameter:
query(string, required): The SQL query to execute.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sam_sql_database_tool-0.3.3-py3-none-any.whl.
File metadata
- Download URL: sam_sql_database_tool-0.3.3-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a7f34b85b06c952eea3fe1596de3a6ca3aab416caeb0ed8f4331421823160ff
|
|
| MD5 |
36e8f5f02c2ac89ae3410c86c7acdcf4
|
|
| BLAKE2b-256 |
852186481cf3e00379f90fdc3abc17275ab8857ae1ca47663602b6ab5e1bad7b
|
Provenance
The following attestation bundles were made for sam_sql_database_tool-0.3.3-py3-none-any.whl:
Publisher:
release.yaml on SolaceLabs/solace-agent-mesh-core-plugins
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sam_sql_database_tool-0.3.3-py3-none-any.whl -
Subject digest:
2a7f34b85b06c952eea3fe1596de3a6ca3aab416caeb0ed8f4331421823160ff - Sigstore transparency entry: 1219338681
- Sigstore integration time:
-
Permalink:
SolaceLabs/solace-agent-mesh-core-plugins@cd412e689d5be369c0072351e589c02e815096d3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/SolaceLabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@cd412e689d5be369c0072351e589c02e815096d3 -
Trigger Event:
workflow_dispatch
-
Statement type: