execute_query
Run read-only SQL queries against PostgreSQL and return JSON results. Mutating statements are blocked, enabling safe schema inspection and data exploration.
Instructions
Execute a read-only SQL query and return results as JSON.
The query must be a SELECT (or WITH … SELECT / EXPLAIN / SHOW / TABLE / VALUES). Mutating statements are rejected before they reach the database.
Args: sql: The SQL query to execute. limit: Maximum number of rows to return (default: 500, max: 5000).
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": {
"sql": "<sql>"
},
"name": "execute_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| limit | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |