Run a read-only SQL query
queryExecute read-only SQL SELECT statements for data analysis. Write the SQL in the target datasource's dialect (get_schema lists every datasource with its dialect). Raw exploration tools do not apply probe redaction and are not bound by schema exposure: they reach any object the datasource credential reaches, and are offered to Administrators, and to members whose Role grants Full; separate access checks apply. Schema exposure governs get_schema, the ontology and approved requests. Rows are positional arrays in columns order. Pass format: "records" for one object per row in returned-column order. Duplicate exact column names collapse to one column at the first position; the surviving value is unspecified. Use unique SQL aliases to preserve every selected value. max_bytes bounds the encoded UTF-8 MCP tool result, after middleware and SDK decoration, including errors, guidance, required protocol metadata, text escaping and whitespace (default 32768; integer 1024–1048576; at most 128 JSON number characters, validated exactly). For requests successfully decoded by the SDK, invalid budgets use a 1024-byte tool-refusal bound. Malformed or overflowing protocol numbers can instead produce SDK JSON-RPC errors before query dispatch, outside CallToolResult and its budget. Infrastructure failures from query remain internal protocol errors with bounded safe text and no source error data. Rows remain a JSON array, one whole row per line. truncated means incomplete output; adapter_truncated and byte_truncated identify the causes. If no row fits, rows is empty with byte_truncated=true; oversized metadata returns result_metadata_exceeds_max_bytes. Failure codes survive diagnostic compaction (diagnostics_omitted); guidance is retained or explicitly refused with guidance_omitted and no query data. Reduce selected columns/rows or raise max_bytes within its bound. For caller-controlled paging use a deterministic unique order and keyset predicate; mutable results require your own snapshot strategy. No cursor or automatic SQL paging is provided.
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": "query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SQL SELECT statement to execute | |
| limit | No | Max rows to return (default: 100, max: 1000) | |
| format | No | Row format (default: compact) | |
| max_bytes | No | Maximum encoded UTF-8 MCP tool-result bytes, including required SDK metadata, escaping and whitespace; default 32768, range 1024–1048576. Excludes JSON-RPC and transport framing. | |
| datasource | No | Optional datasource ID to target. Omit to use the project's configured default; required when the project has multiple datasources and no default is configured. Each datasource has its own SQL dialect: get_schema lists every datasource with its type, dialect and identifier quote, and every result carries datasource_type and dialect. A datasource that has not finished setup is refused with datasource_not_ready. Use datasource (not datasource_id) here; Request authoring uses datasource_id. Unknown top-level arguments and malformed supplied datasource values return invalid_parameters before datasource selection. Supply a nonzero UUID string, or omit datasource intentionally to use the default/sole datasource. | |
| natural_language_context | No | The natural language question that prompted this query. When provided, the query is saved to history for future reference and learning. |