Skip to main content
Glama
xmpuspus

ph-civic-data-mcp

by xmpuspus

Query a PSA OpenSTAT dataset

query_psa_dataset
Read-onlyIdempotent

Query a PSA OpenSTAT dataset by providing explicit value codes for every dimension, with a configurable row limit and error status reporting.

Instructions

Run one bounded query against a PSA OpenSTAT dataset.

Every dimension needs an explicit list of value codes from describe_psa_dataset. That is a hard requirement, not a convention. PXWeb expands an unselected dimension to all of its values, and PSA answers the resulting full-cube request with an HTTP 403. PSA writes a missing cell as "..", and those come back as null, never zero. Examples:

one dataset, every dimension given an explicit code list

query_psa_dataset( "1F/FY/0241F3DF013.px", {"Year": ["2"], "Major Island Group": ["0", "2"], "Among Families/Population": ["0"]}, )

On failure: a bad path, a bad max_rows, or a rejected selection (a missing dimension, an unknown code, or "all"/"*") sets validation_error true and data_status "invalid_request", before any request goes out. An OpenSTAT outage sets upstream_error true and data_status "unavailable". A zero-row reply for a nonzero selection, or a row whose key does not map to the declared columns, sets data_status "indeterminate" and upstream_error true on a real HTTP 200. All four cases return an empty rows list.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_rowsNoCap on returned rows (1-5000, default 500).
selectionsYesDimension code -> list of value codes, covering every dimension the dataset declares. "all" and "*" are rejected. Example: {"Year": ["2"], "Major Island Group": ["0", "2"], "Among Families/Population": ["0"]}.
dataset_pathYesRelative `.px` path, for example "1F/FY/0241F3DF013.px".

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
noteNo
rowsYes
titleNo
sourceYesUpstream data source name.
caveatsYes
licenseNo
row_countYes
truncatedNo
disclaimerNo
source_urlYesCanonical OpenSTAT URL used.
dataset_pathYes
upstream_errorNoTrue when OpenSTAT was unreachable. Not an empty result.
requested_cellsNo
reference_periodNoData vintage read from the table's own time dimension.
validation_errorNoTrue when the caller's arguments were rejected before any request.
data_retrieved_atYes
total_rows_availableNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.0
    • changedInput schema / properties / dataset_path / description
      Previous value: -"Relative `.px` path, e.g. \"1F/FY/0241F3DF013.px\"."New value: +"Relative `.px` path, for example \"1F/FY/0241F3DF013.px\"."
  2. Addedv0.6.0

TDQS

A4.5/5.0
Behavior5/5

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

The description discloses detailed error handling: validation errors, upstream outages, indeterminate statuses, and empty rows on failure. It also reveals that missing cells are null, never zero, which is not covered by the annotations.

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

Conciseness5/5

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

The description is long but every sentence serves a purpose: stating the core function, the critical all-dimensions requirement, an example, and detailed failure semantics. It is front-loaded with the most important constraint and well-organized.

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?

The description covers all relevant operational aspects: required parameters, constraints, error conditions, and return behavior for failures. It is sufficient for an agent to call the tool correctly without needing to see the output schema.

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?

The input schema already provides extensive parameter descriptions, and the description reinforces key points like the need to cover every dimension and the rejection of 'all'/'*'. It adds the practical hint to obtain value codes from describe_psa_dataset, which aids parameter selection.

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 clearly defines the tool as running a bounded query against a specific PSA OpenSTAT dataset. It distinguishes this from sibling tools like browse or search by focusing on retrieving data rows for a known dataset path.

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

Usage Guidelines3/5

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

The description explains how to use the tool (must provide explicit value codes for all dimensions, avoid 'all'/'*') but does not explicitly state when to choose this tool over alternatives like describe_psa_dataset or search_psa_catalog. There is no comparison to siblings, so usage context is inferred.

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