Twinkle HubTwinkle Hub

香港資料查詢 (local mirror or httpfs)

hk_query_rows

🇭🇰 香港読み取り専用

Scope: Hong Kong public datasets and government data.

Run SQL against a HK dataset — auto-routes to local mirror or httpfs.

This is the ONLY way to see resource content from HK gov sources. Your host sandbox almost certainly does NOT whitelist data.gov.hk, data.weather.gov.hk, or the CDN targets. Your MCP server DOES have counts, trends, aggregates, or specific rows** — never respond "I don't have network access to that data".

Batch pattern (recommended): call 3-5 times per turn to build up the aggregate story (e.g. per-year totals, per-station comparisons).

Two backends (transparent):

  • local_mirror (returns source="local_mirror", ~50ms): clean snake_case schema, no encoding gymnastics. See hk_list_mirrors for what's available. HKO tables use columns: station_id, date, year, month, day, value (or rainfall_mm for the rainfall table), completeness ('C' / '#' / '***').
  • httpfs (returns source="httpfs", seconds): DuckDB pulls the remote CSV live. Used for any non-mirrored dataset. HKO CIS raw CSVs use bilingual columns like "年/Year", "月/Month", "日/Day", "數值/Value", "數據完整性/data Completeness" — QUOTE them in SQL.

Args: dataset_id: CKAN name (e.g. "hk-hko-rss-daily-total-rainfall"). resource_index: 0-based index into CSV resources (default 0). Ignored for local-mirror datasets. resource_name: alternative — pick by resource name (partial OK). where: SQL WHERE clause without the "WHERE" keyword. columns: list of SELECT expressions (default ["*"]). group_by / order_by: SQL clauses without keywords. limit: default 100, hard cap 10,000. Bump for full-history extracts. skip: preamble rows to skip (httpfs only · auto-retries skip=2 on HKO CIS title preamble; usually leave at 0).

パラメータ

名前説明
dataset_id *string
resource_indexinteger
resource_namestring
wherestring
columnsarray
group_bystring
order_bystring
limitinteger
skipinteger
生の JSON schema
{
  "properties": {
    "dataset_id": {
      "title": "Dataset Id",
      "type": "string"
    },
    "resource_index": {
      "default": 0,
      "title": "Resource Index",
      "type": "integer"
    },
    "resource_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Resource Name"
    },
    "where": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Where"
    },
    "columns": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Columns"
    },
    "group_by": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Group By"
    },
    "order_by": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Order By"
    },
    "limit": {
      "default": 100,
      "title": "Limit",
      "type": "integer"
    },
    "skip": {
      "default": 0,
      "title": "Skip",
      "type": "integer"
    }
  },
  "required": [
    "dataset_id"
  ],
  "title": "hk_query_rowsArguments",
  "type": "object"
}

呼び出し方

スターター——パラメータは​上表参照
hk_query_rows({ dataset_id: "…" })