Skip to main content
Glama

query_dataset

Run custom ODSQL queries on SNS Transparency portal datasets to retrieve filtered, aggregated, or grouped official health statistics.

Instructions

Run an ODSQL query on any SNS Transparency portal dataset (Opendatasoft Explore API v2.1).

Use after search_datasets for anything the curated tools don't cover. Clauses are ODSQL:

  • where: instituicao like "santa maria" and tempo >= date'2026-01-01' (like is a case- and accent-insensitive "contains"; dates use date'YYYY-MM-DD')

  • select: tempo, instituicao, total_urgencias or aggregates sum(total_urgencias) as total

  • group_by: regiao or tempo (combine with aggregates in select)

  • order_by: tempo desc Most hospital-activity datasets (field tempo, monthly) store YEAR-TO-DATE CUMULATIVE values: December is the annual total; a single month = this month minus the previous one. Many datasets have a regiao and an instituicao (or entidade) field. Official statistics, not live data.

Args: dataset_id: e.g. "ocupacao-do-internamento" (from search_datasets). where, select, group_by, order_by: ODSQL clauses (optional). limit: Rows to return (default 20, max 100). offset: Skip rows, for paging.

Input Schema

NameRequiredDescriptionDefault
limitNo
whereNo
offsetNo
selectNo
group_byNo
order_byNo
dataset_idYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior4/5

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

With no annotations, the description carries the whole burden and does substantial work: it discloses the YTD-cumulative semantics of the `tempo` field (December = annual total, single month = delta), which is a genuine data-shape trap an agent would otherwise fall into. It also states limits (default 20, max 100) and that this is official statistics, not live data. It stops short of stating read-only/safety or error behavior explicitly, keeping it just below a 5.

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 and use-condition, then clause reference, then args — good ordering with no repetition of the schema. The clause examples are long but each demonstrates syntax the schema cannot express; the leftover argparse-style 'Args:' block is mildly redundant given the schema fields exist.

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?

Output schema exists, so return-format explanation is unnecessary; the description instead supplies what the schema can't — query language semantics, dataset discovery path, field conventions (`tempo`, `regiao`, `instituicao`/`entidade`), and the cumulative-value caveat. Nothing essential for a correct call is missing.

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

Parameters5/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 compensate entirely, and it does: each ODSQL clause gets a concrete example (`instituicao like "santa maria" and tempo >= date'2026-01-01'`) including the non-obvious case/accent-insensitive `like` and date literal syntax, plus aggregate form for select. limit/offset/dataset_id semantics and paging purpose are all spelled out.

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 an ODSQL query on any SNS Transparency portal dataset' — and names the API behind it (Opendatasoft Explore API v2.1). It also distinguishes itself from the curated siblings ('anything the curated tools don't cover'), so an agent can route correctly without opening other schemas.

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?

'Use after search_datasets for anything the curated tools don't cover' gives an explicit precondition plus the alternative tools it supersedes. The dataset_id arg reinforces the ordering by pointing back to search_datasets as the discovery step.

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