Skip to main content
Glama

Query a dataset (PIT-safe)

query_dataset
Read-onlyIdempotent

Query rows with built-in look-ahead protection.

★ POINT-IN-TIME: pass `as_of` (YYYY-MM-DD) for backtesting/agent-learning. For non-point-in-time-safe
datasets (fundamentals, monthly_revenue, dividend_policy…) rows are filtered by DISCLOSURE date <= as_of,
so the agent only sees what was public at that moment. Omit as_of only for present-day lookups (warned).

★ IF A VALUE IS IN `coverage.missing`, IT IS NOT AVAILABLE. Say it is not available. **Never
estimate it, interpolate it, infer it from a neighbouring period, or carry the last known value
forward.** `coverage.missing` lists exactly what was requested and not returned, with a reason
(e.g. "9999 在 as_of 當日未上市"). An empty `data` array alongside a populated `missing` list is a
complete and correct answer to "what do you have" — not an invitation to fill the gap.

★ EVERY VALUE IS ATTRIBUTABLE. `provenance` carries {source, source_role, ingested_at, revision,
provenance_uri}; `meta.query_id` names this exact question. Quote the query_id when reporting a
number — `replay_query(query_id)` returns the bytes that were served, so the claim can be checked
later. `freshness.is_stale` is computed server-side against the dataset's own cadence budget;
`null` means it could not be determined, which is NOT the same as fresh.

Args:
    dataset_id: see list_datasets. tickers: e.g. ['2330','2317']. start/end: 'YYYY-MM-DD' range.
    as_of: knowledge-time cutoff 'YYYY-MM-DD' (use for backtests). limit: <=5000.
Returns: {meta:{table,coverage,row_count,as_of_applied,point_in_time_safe,warnings,query_id},
          data:[...], provenance:{...}, coverage:{requested,returned,missing,reason},
          freshness:{status,latest_available,expected_lag,is_stale}}
Example: query_dataset('income_statement', tickers=['2330'], as_of='2023-06-30')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endNo
as_ofNo
limitNo
startNo
cursorNo
tickersNo
dataset_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataNo
hintNo
metaNo
errorNo
statusNo
blockedNo
messageNo
coverageNo
freshnessNo
provenanceNo
not_investment_adviceNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedOutput schema / $defs / Freshness / properties / expected_lag_unit
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Expected Lag Unit"
      +}
  2. Changed1 schema field changed
    • addedInput schema / properties / cursor
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Cursor"
      +}
  3. Added
  4. Removed
  5. Changed9 schema fields changed
    • addedOutput schema / $defs / Coverage
      Added value: +{
      +  "additionalProperties": true,
      +  "description": "What was asked for and what came back.\n\n``missing`` is THE anti-hallucination field. An agent handed an empty list for a ticker it asked\nabout will reason about the absence; an agent handed ``missing:[\"9999\"]`` with a reason cannot.",
      +  "properties": {
      +    "from_": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "From"
      +    },
      +    "missing": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Missing"
      +    },
      +    "reason": {
      +      "anyOf": [
      +        {},
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Reason"
      +    },
      +    "reason_by_item": {
      +      "anyOf": [
      +        {
      +          "additionalProperties": {
      +            "type": "string"
      +          },
      +          "type": "object"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Reason By Item"
      +    },
      +    "requested": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Requested"
      +    },
      +    "returned": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Returned"
      +    },
      +    "to": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "To"
      +    }
      +  },
      +  "title": "Coverage",
      +  "type": "object"
      +}
    • addedOutput schema / $defs / Freshness
      Added value: +{
      +  "additionalProperties": true,
      +  "description": "Server-computed, against the dataset's OWN cadence budget.\n\n``is_stale`` is null — never false — when it could not be determined: a missing measurement is\nnot evidence of freshness. A dataset with no calendar budget (a reference table, an event feed\nthat fires a few times a year) is ``AS_OF`` and is never stale.",
      +  "properties": {
      +    "age_days": {
      +      "anyOf": [
      +        {
      +          "type": "integer"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Age Days"
      +    },
      +    "detail": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Detail"
      +    },
      +    "expected_lag": {
      +      "anyOf": [
      +        {
      +          "type": "integer"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Expected Lag"
      +    },
      +    "is_stale": {
      +      "anyOf": [
      +        {
      +          "type": "boolean"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Is Stale"
      +    },
      +    "latest_available": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Latest Available"
      +    },
      +    "status": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Status"
      +    }
      +  },
      +  "title": "Freshness",
      +  "type": "object"
      +}
    • addedOutput schema / $defs / Provenance
      Added value: +{
      +  "additionalProperties": true,
      +  "description": "Where one value came from. Fields are null when unknown rather than absent — an absent key\nreads as \"this API does not do provenance\", a null reads as \"we do not know this one\".",
      +  "properties": {
      +    "ingested_at": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Ingested At"
      +    },
      +    "provenance_uri": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Provenance Uri"
      +    },
      +    "revision": {
      +      "anyOf": [
      +        {},
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Revision"
      +    },
      +    "source": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Source"
      +    },
      +    "source_role": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "default": null,
      +      "title": "Source Role"
      +    }
      +  },
      +  "title": "Provenance",
      +  "type": "object"
      +}
    • addedOutput schema / $defs / QueryMeta / properties / envelope_version
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Envelope Version"
      +}
    • addedOutput schema / $defs / QueryMeta / properties / query_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Query Id"
      +}
    • addedOutput schema / properties / coverage
      Added value: +{
      +  "anyOf": [
      +    {
      +      "$ref": "#/$defs/Coverage"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • addedOutput schema / properties / freshness
      Added value: +{
      +  "anyOf": [
      +    {
      +      "$ref": "#/$defs/Freshness"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • addedOutput schema / properties / not_investment_advice
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Not Investment Advice"
      +}
    • addedOutput schema / properties / provenance
      Added value: +{
      +  "anyOf": [
      +    {
      +      "$ref": "#/$defs/Provenance"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
  6. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare readOnlyHint, openWorldHint, idempotentHint, and destructiveHint=false. The description adds substantial behavioral context beyond these: the point-in-time filtering logic based on disclosure dates, the exact meaning of coverage.missing and the directive to not fill gaps, the attribution via provenance and query_id, and the server-side freshness computation with null semantics. This significantly enriches what the agent needs to interpret results correctly. No contradiction with 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 dense but extremely well-structured: it opens with a one-line summary, then uses clear bullet points with bold headers for each critical behavioral rule, followed by a concise args list and an example. Every sentence carries essential information with no filler. The point-in-time and missing-value rules are front-loaded, ensuring the most consequential guidance is immediately visible. It earns a perfect score for efficiency and organization.

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 the tool's complexity (7 parameters, rich output schema), the description covers the most important usage aspects: as_of semantics, missing-value handling, provenance, freshness, and a concrete example. The output schema exists, so detailed return-value explanations are unnecessary. However, the omission of cursor leaves a small gap in the parameter coverage, and the description does not mention pagination or how to retrieve additional pages. These are minor but real gaps, so a 4 is warranted.

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 0% schema description coverage, the description must compensate for all parameters. It covers dataset_id, tickers, start/end, as_of, and limit with format examples and constraints (limit <=5000). However, it omits the 'cursor' parameter entirely, which is present in the schema and likely used for pagination. Since cursor is not mentioned, an agent might not know it exists or how to use it. The description handles the most critical parameters but leaves one gap, so a 4 is appropriate.

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 states a specific verb ('Query rows') and a clear resource (dataset) with a distinctive feature: built-in look-ahead protection. It clearly distinguishes the tool's role as the primary data-querying entry point among a large set of sibling tools, and the point-in-time emphasis separates it from simpler lookups. The purpose is unambiguous and immediately actionable.

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?

The description gives explicit usage guidance: when to pass as_of (backtesting/agent-learning) and when to omit it (present-day lookups, with a warning). It also specifies how to handle missing values (never estimate) and when to use replay_query for verification. While it doesn't explicitly name alternatives, the guidance is specific and conditions are clear, covering both when and how to use the tool effectively.

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