Skip to main content

run_select_query

Executes a SELECT statement against the configured providers and returns the result rows. Read only - mutations and lifecycle operations are not accepted; use run_mutation_query or run_lifecycle_operation for those.

Result rows are returned to the client but are deliberately excluded from the audit log.

See also: [ MCP overview ] [ validate_select_query ] [ list_methods ] [ SELECT language spec ]


Inputs​

ArgumentRequiredDescription
sqlYesA SELECT statement. Metadata statements (SHOW, DESCRIBE, DESC, EXPLAIN) are classed as read-only by the policy gate and accepted too; DESC is recognised in StackQL releases from v0.12.732.
row_limitNoCap on the number of rows returned to the client. 0 (default) means no client-side cap.
sourceNoQuery library entry ID when the SQL came from query_library_get. Attribution only; does not change execution or approvals.
formatNoText rendering: markdown or json. When omitted, uses the server's render setting.

Output​

RendererShape
Table{rows: [...]} - one object per row, keyed by column name; plus {messages: [...]} when the engine reported messages for the statement

From v1.1.959, per-statement engine messages, such as a provider HTTP error, are returned in the tool result: a messages array beside rows in the structured payload and a labelled messages block after the rendered rows. Long messages are truncated and the list is capped, with a marker reporting anything cut; a statement with no messages has no messages field. An empty result with a 404 message is the normal answer for an object that does not exist. Over the reverse_proxy backend, engine messages are not available to the client.


Gating​

Allowed in every server mode (read_only, safe, delete_safe, full_access) when every statement in the payload is read-only. From v1.0, INSERT, UPDATE, REPLACE, DELETE and EXEC are refused by this tool in every mode, including full_access, with an error naming run_mutation_query or run_lifecycle_operation. A payload holding several statements is classed by its most privileged statement, so a mutation behind a leading SELECT is refused in the same way. The tool declares destructiveHint: false and openWorldHint: true.


Example​

Try this prompt with any MCP client with the StackQL MCP server registered:

List the VPC networks in my Google Cloud project my-project
and tell me which ones use auto subnet creation.

Here's an example in Claude Desktop: