execute_query
Perform read-only SQL SELECT queries to fetch, count, aggregate, and join data from tables. Supports configurable limits, timeout, and output formats.
Instructions
Execute read-only SELECT queries. Writes are blocked.
LEVEL: Data (actual table data retrieval)
USE FOR: fetching data, counting rows, aggregations, joins. DO NOT USE FOR: INSERT/UPDATE/DELETE (use analyze_impact first).
ERROR RECOVERY:
"relation does not exist": Verify table name with get_schema()
"permission denied": User lacks SELECT privilege on table
"query timeout": Reduce limit, add WHERE clause, or increase timeout_ms
"not connected": Call connect() first
Examples: execute_query(query='SELECT * FROM users LIMIT 10') execute_query(query='SELECT COUNT(*) FROM orders')
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>"
},
"name": "execute_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | SQL SELECT query | |
| limit | No | Max rows (1-50000) | |
| timeout_ms | No | Timeout in ms (5 min default) | |
| format | No | Output format | json |
| url | No | Database URL |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |