Thailand NSO MCP Server
This server lets you discover, query, and analyze Thailand's official statistics from the National Statistical Office (NSO) via the SDMX REST API using natural language.
Discover Dataflows: Search ~900 TNSO datasets by keyword (Thai or English) or by required dimension codes to find relevant dataflows.
Get Data Structure: Retrieve the full DSD for any dataset — ordered dimensions and their associated codelists.
Get Constraints: Fetch all valid dimension values (with Thai/English labels) and the available time range for a dataflow. Time periods use Buddhist Era (BE = Gregorian + 543, e.g. 2024 → 2567).
Get Codelist Descriptions: Retrieve Thai and English labels for every code in a given codelist (e.g., province codes, sex codes).
Resolve Concepts: Look up a TNSO SDMX concept ID to get its Thai or English name.
Fetch Data: Query statistical observations as a TSV table with dimension filtering and Buddhist Era time ranges. Includes self-diagnosis of empty results with suggested valid alternatives.
Check Data Availability: Pre-flight check to verify a filter/period combination will return results before a full fetch.
Look Up Territorial Codes: Find official Thai geography codes for regions, provinces (77 changwat), or districts by Thai or English name — essential before filtering by geography.
Cache Diagnostics: Inspect the on-disk cache health and contents for troubleshooting.
Typical workflow:
Use
discover_dataflowsto find a relevant dataset.Use
get_constraintsto understand valid filter values and time ranges.Optionally use
get_territorial_codesto find province/region codes.Use
get_datato fetch the actual observations.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Thailand NSO MCP Server Find aging index data for Thailand"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Research repository — not for data access.
aard-ai/tnso-mcp-server is a research artefact, built for studying how MCP servers behave against
different statistical agencies' SDMX endpoints. It is not maintained, is not published to
any package registry, and must not be used as an MCP server for data access.
Thailand NSO MCP Server
An MCP server that lets an LLM discover, query and
analyse Thailand's official statistics from the National Statistical Office (NSO,
agency TNSO) via the SDMX REST API — in natural language.
This is a lightweight MCP that uses keyword search (this is not the Aard MCP).
It should be effective for e.g. searching for indicators or dataflows.
Note that this lightweight approach is much less effective for certain question types such as "Compare Bangkok and Chon buri", or "Tell me about trade of all fish that are not tuna". These kinds of questions benefit from structure-based search across all data sources, just two factors that make the Aard MCP different from other tools.
When connected to your chat tool (e.g. Gemini or Claude) it can generate analysis like the below:
This implementation based on a port of ondata/istat_mcp_server
(Italy / ISTAT), adjusted to point to the Thaliand NSO SDMX endpoint at
https://ns1-stathub.nso.go.th/rest.
It uses a 9-tool workflow (like the ISTAT MCP), same two-layer caching; the data source, agency, languages (Thai/English) and geography (Thai provinces) are swapped in.
Note we use Buddhist Era dates. TNSO publishes time periods in the Buddhist Era calendar (BE = Gregorian + 543). So
2567means 2024. Passstart_period/end_periodas BE years.
Tools
Tool | What it does |
| Search ~900 TNSO dataflows by keyword (Thai/English; any keyword matches (OR), or |
| Dimensions + codelists for a data structure (DSD). |
| Valid values (with labels) per dimension + available time range. Start here. |
| Thai/English labels for every code in a codelist. |
| Resolve an SDMX concept id to its Thai/English name. |
| Fetch observations as a TSV table (+ reproducible CSV/curl URLs). On an empty result it self-diagnoses (invalid codes / out-of-range period) and suggests verified non-empty alternatives. |
| Pre-flight check that a specific filter/period combination returns rows before a full |
| Thai geography codes: region ( |
| Inspect the on-disk cache. |
Typical workflow: discover_dataflows → get_constraints → get_data
(use get_territorial_codes first when you need province/region codes). get_data
self-diagnoses empty results and suggests working alternatives; use
check_data_availability to pre-check a combination before fetching.
Related MCP server: mcp-uk-ons
Install & run
Requires Python ≥ 3.11. Using uv (recommended):
git clone https://github.com/aard-ai/tnso-mcp-server.git
cd tnso-mcp-server
uv venv
uv pip install -e ".[dev]"
# Run the server (stdio transport)
uv run python -m tnso_mcp_serverOr with pip:
cd tnso-mcp-server
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
python -m tnso_mcp_serverRegister with an MCP client
Claude Code:
claude mcp add tnso -- uv --directory /abs/path/to/tnso-mcp-server run python -m tnso_mcp_serverClaude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"tnso": {
"command": "uv",
"args": ["--directory", "/abs/path/to/tnso-mcp-server", "run", "python", "-m", "tnso_mcp_server"]
}
}
}Configuration
Copy .env.example to .env to override defaults (API base URL, timeouts, cache TTLs,
log level, dataflow blacklist). All values have sensible defaults, so .env is optional.
Example
discover_dataflows(keywords="aging")
-> DF_01DI_IND_AGING — "Aging Index dataflow"
discover_dataflows(covers={"CWT": ["10", "20"]})
-> every dataflow whose data covers both Bangkok (10) and Chon Buri (20)
get_constraints(dataflow_id="DF_01DI_IND_AGING")
-> dimensions POP_IND, SEX, AREA, CWT, ...; TIME_PERIOD range 2557–2567 (BE)
get_territorial_codes(level="province", name="bangkok")
-> { code: "10", name_en: "Krung Thep Maha Nakhon (Bangkok)", name_th: "กรุงเทพมหานคร" }
get_data(dataflow_id="DF_01DI_IND_AGING", dimension_filters={"CWT": ["10"]}, start_period="2560", end_period="2567")
-> TSV table of the aging index for Bangkok, 2017–2024Tests
uv run pytest -m "not integration" # fast unit tests (no network)
uv run pytest -m integration # live tests against the real TNSO API
uv run pytest # everythingMIT (same as the upstream istat_mcp_server).
Available Tools
8 toolsdiscover_dataflowsA
Discover available TNSO (Thailand National Statistical Office) dataflows. Optionally filter by comma-separated keywords (matched against id, Thai/English name and description). Start here to find a dataset, then call get_constraints.
Inputs: keywords.
get_cache_diagnosticsA
Check persistent-cache health (exists, size, writability). Pass debug=true to additionally reveal the cache path and stored keys (host-sensitive). For debugging.
Inputs: debug.
get_codelist_descriptionA
Get Thai and English labels for every code in a codelist (e.g. 'CL_CWT').
Inputs: codelist_id (required).
get_conceptsA
Resolve a TNSO SDMX concept id to its Thai or English name (searches all TNSO concept schemes; result cached). Use lang='th' or lang='en'.
Inputs: concept_id (required), lang.
get_constraintsA
Get all valid dimension values (with Thai/English labels) and the available time range for a dataflow. One call returns everything needed to build a get_data query. Time periods are Buddhist Era (BE = Gregorian + 543).
Inputs: dataflow_id (required).
get_dataA
Fetch observations for a dataflow as a TSV table, with reproducible CSV/curl URLs. Supports dimension filtering and a time range. Omit dimensions from dimension_filters to get all their values; pass multiple codes per dimension as an array. If no period is given, the latest available year is returned. IMPORTANT: start_period/end_period are Buddhist Era years (e.g. 2567 = 2024).
Inputs: dataflow_id (required), detail, end_period, start_period, +2 more.
get_structureA
Get the data structure (DSD) for a datastructure id: the ordered list of dimensions and the codelist each uses. Fast path when you already know the codes.
Inputs: datastructure_id (required).
get_territorial_codesA
Look up Thai geography codes used by the AREA / CWT dimensions: level='region' (CL_AREA), 'province' (CL_CWT, 77 changwat), or 'district' (CL_AMPHOE). Filter by 'name' (Thai or English substring). Use this to find codes before calling get_data.
Inputs: name, level.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a distinct purpose: discovery, structure, constraints, data retrieval, code lookups, and diagnostics. No overlap exists; even get_codelist_description and get_constraints serve different needs.
All tool names follow a consistent verb_noun pattern with snake_case (e.g., discover_dataflows, get_constraints, get_data), making it predictable for agents.
With 8 tools, the set is well-scoped for a statistical data server, covering discovery, structure, query building, data retrieval, and code lookups without unnecessary tools.
The tool surface covers the full workflow: discover dataflows, get structure and constraints, fetch data, and resolve codes. No obvious gaps for a public statistics API.
Maintenance
Related MCP Connectors
Search and query 1,500+ OECD statistical datasets via SDMX. Keyless.
Unofficial Eurostat MCP — wraps Eurostat Statistical Data API (no auth required)
Query IMF SDMX 3.0 macroeconomic dataflows — WEO, BOP, CPI, exchange rates, 190 countries.
政府統計 (e-Stat) の API を通じて、統計データやメタ情報を取得するためのサービスです。
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides seamless access to official Ukrainian government statistics from the State Statistics Service via their SDMX API. It enables users to query bilingual datasets across domains like energy, demographics, and trade using flexible filtering and metadata exploration tools.5 npm50MIT
- AlicenseNot gradedqualityCmaintenanceEnables querying UK Office for National Statistics datasets and their editions through natural language, with no authentication required.72 npmMIT
- AlicenseAqualityDmaintenanceProvides access to UK economic, social, and labour-market statistics via the ONS beta and Nomis APIs, enabling discovery and retrieval of time series, datasets, and census data.18MIT
- AlicenseAqualityCmaintenanceEnables querying, exploring, and downloading ISTAT statistical datasets via SDMX REST API, with unified metadata, territorial code resolution, and data extraction.7MIT