Skip to main content
Glama
Replaced by its MCP Registry listing

This endpoint is listed in the official MCP Registry as FactIQ. If you published it, claim ownership there.

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. Join on the text key (JOIN series s ON s.series_id = d.series_id), never on the integer series.id; the unit column is measurement_units. 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/…).

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": {
      "schema": "<schema>",
      "sql": "<sql>"
    },
    "name": "run_sql"
  }
}

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.5/5.0
Behavior5/5

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

Annotations only declare readOnly/destructive status; the description adds substantial context beyond that — a 30s statement timeout, the read-only role rejecting INSERT/UPDATE/DELETE/DROP, the 50-row cap with a `truncated` flag, the coverage_note/missing_periods behavior, auto_retry semantics, and the page mechanic restricted to a single schema. It also warns about a silent-wrongness trap (LAG offset vs date_trunc join) that no structured field could convey.

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?

Front-loaded with purpose, then proceeds in a logical order: constraints, id resolution caveats, truncation policy, period-comparison rule, paging exception, safety. Dense but nearly every sentence carries an actionable rule; the LAG/LEAD parenthetical is the one spot that runs longer than it needs to.

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?

An output schema exists, yet the description still usefully explains the signals that matter (`truncated`, `has_more`, `coverage_note`, `missing_periods`), which is what an agent needs to react correctly. The remaining gap is the undocumented `explore` and `question` parameters, which an agent cannot reason about from either source.

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 must carry parameter meaning. It explains `schema` (single-schema scope), `sql`, `page` (only valid on nasa_fires, 50 rows per page, requires ORDER BY), and `auto_retry` (server-side reviser on zero rows) — but `explore` and `question` are never mentioned or distinguished from each other, leaving two of six parameters undocumented anywhere.

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?

Names a specific verb and resource ('Run a read-only SELECT against the FactIQ data warehouse') and immediately states scope ('scoped to one schema') plus the capability that differentiates it ('power tool for joins, pivots and aggregation'). It also distinguishes itself from sibling get_series by routing single-series work there.

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?

Gives explicit when-to-use and when-to-do-something-else rules: aggregate in SQL when truncated rather than fetching raw rows, prefer get_series with transform for one series, and prefer counts/totals over paging fire detections. Alternatives and the conditions selecting them are stated, not implied.

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