Skip to main content
Glama

run_query

Read-only

Execute ad-hoc SQL queries against a data source with safety guards, returning results as a table or JSON. Confirm tables and columns first for best use.

Instructions

Execute an ad-hoc SQL query against a data source and return the resulting rows. Every query passes through the SQL safety guard, which blocks destructive statements (DROP/TRUNCATE/ALTER, DELETE/UPDATE without WHERE) and flags PII columns and expensive full scans; results are cached in memory. Behavior: returns up to max_rows rows as a markdown table or JSON, with the column list and a truncation note when there are more rows. Usage: confirm table and column names with list_tables and get_table_columns first; for natural-language questions, plan the SQL with smart_query before calling this. To run an already-saved query instead, use get_query_result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSQL query to execute
formatNoOutput format: table (markdown) or jsontable
max_ageNoRedash cache TTL in seconds (0 to 604800). Defaults to REDASH_DEFAULT_MAX_AGE env var
max_rowsNoMax rows to return (1 to 10000, default 100)
timeout_secsNoQuery execution timeout in seconds (1 to 300, default 30)
data_source_idYesData source ID from list_data_sources
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations (readOnlyHint=true) are aligned and the description adds significant behavioral detail: safety guard that blocks destructive statements, PII flagging, caching, memory result, max rows, truncation notes, and format options. No contradiction; the annotation is reinforced.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single paragraph that efficiently packs purpose, safety, behavior, and usage tips. It is front-loaded with the main action. A slight reduction in length could be achieved, but it remains clear and informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 6 parameters (2 required), 100% schema coverage, and no output schema, the description covers the core behavior, safety, caching, format, and prerequisites. It could elaborate on return value structure (e.g., exact columns), but the mention of 'column list' and 'truncation note' provides enough context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema coverage, baseline is 3. The description adds value by explaining the overall behavior ('returns up to max_rows rows as a markdown table or JSON'), which gives context to parameters like 'format' and 'max_rows'. It does not repeat all parameter descriptions but enriches their meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description starts with a clear action verb ('Execute') and specifies the resource ('ad-hoc SQL query against a data source') and the outcome ('return the resulting rows'). It distinguishes from siblings like 'get_query_result' and 'smart_query' by explicitly stating when to use them instead.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance is provided: confirm table/column names with 'list_tables' and 'get_table_columns' first, use 'smart_query' for natural-language questions, and use 'get_query_result' for saved queries. It also notes that the SQL safety guard blocks destructive statements, clarifying when not to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/seob717/redash-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server