Skip to main content
Glama

Run SQL query

run_sql
Read-only

Run a read-only SELECT against the FactIQ data warehouse, scoped to one schema — the power tool for joins, pivots and aggregation.

Read-only role, 30s statement timeout, with FactIQ's query transforms and series-metadata enrichment. Resolve ids from series before filtering data_points. auto_retry=true opts into a server-side reviser on zero rows. See the factiq://guide/sql resource.

Returns at most 50 rows. If the query matches more, the result is flagged "truncated": true — that is your cue to aggregate or compute in SQL (GROUP BY, date_trunc, a SUM/AVG/rank/ratio) and return that, NOT to try to fetch the raw rows. A chart or a summary needs the aggregated result, and large raw results don't fit in context anyway.

Year-over-year and other period comparisons must join on the calendar period (date_trunc('month', prior.time) = date_trunc('month', cur.time) - interval '1 year' — the stored day of the month varies by source, so never compare exact dates), never on a row offset such as LAG(value, 12) OVER (ORDER BY time): a series with one missing month compares the wrong periods for the twelve rows after the gap (LEAD: the twelve before it) and the numbers still look plausible. For one series prefer get_series with transform. When the result carries a coverage_note, the rows have periods with no observation (listed in missing_periods, per series): name them in the answer, do not interpolate, and label any aggregate that spans them as partial.

page is the one exception and works only on the nasa_fires schema, where a row is a single fire detection that belongs to no series and so cannot be aggregated into one. Each page holds 50 rows; the answer carries page and has_more, and you read the next block with page=2, page=3 and so on. Give the query an ORDER BY, otherwise Postgres may return the same row on two pages and never return another. Still prefer a count or a total when that answers the question — paging through thousands of detections does not.

Runs through FactIQ's read-only database role, which rejects any attempt to modify data (INSERT/UPDATE/DELETE/DROP/…).

Input Schema

NameRequiredDescriptionDefault
sqlYes
pageNo
schemaYes
exploreNo
questionNo
auto_retryNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint/destructiveHint=false, but the description adds substantial behavioral context: the read-only role that rejects INSERT/UPDATE/DELETE/DROP, a 30s statement timeout, query transforms and series-metadata enrichment, the 50-row cap with `truncated`, and coverage_note/missing_periods semantics. Slight deduction only because the treatment is encyclopedic rather than focused.

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 opening sentence front-loads purpose and the paragraphs are organized by concern (limits, period comparison, pagination, safety). It is long and includes some redundancy (the read-only role is stated at the top and restated at the bottom), but nearly every sentence carries actionable content.

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

Completeness5/5

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

For a complex power tool with six parameters, an output schema, and truncation/pagination/coverage behaviors, the description covers the failure modes an agent must anticipate. An output schema exists, so return-value enumeration isn't required, and the description still flags the fields that change how the agent must respond.

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

Parameters3/5

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

Schema description coverage is 0%, so the description carries the full burden. It documents `page` (nasa_fires only, 50 rows per page), `auto_retry` (server-side reviser on zero rows), and scoping via `schema`, but never explains `explore` or `question` — two of six parameters are left undocumented in both schema and description.

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?

States a specific verb and resource ('Run a read-only SELECT against the FactIQ data warehouse, scoped to one schema') and positions itself as 'the power tool for joins, pivots and aggregation', which differentiates it from the sibling get_series it later names for single-series work.

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?

Explicitly routes the agent: prefer get_series with transform for one series, aggregate in SQL rather than fetch raw rows on truncation, use `page` only on the nasa_fires schema, and use auto_retry on zero rows. Also describes the required join idiom for period comparisons and warns against LAG offsets — real when-to-use guidance, not just an implied context.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources