swiss-statistics-mcp

v0.9.0
io.github.malkreide/swiss-statistics-mcp Checked 4 hours ago Published 18 days ago

BFS STAT-TAB PxWeb API for official Swiss statistics

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

bfs_browse_catalog

Browse the BFS catalogue: the theme list, or the datasets within a theme. Two modes in one tool (`mode` in the result says which ran): - Omit `theme_code` → list all 21 statistical themes with their 2-digit codes and dataset counts (the taxonomy of Swiss federal statistics). - Provide `theme_code` → list the datasets in that theme (table IDs + titles) to feed bfs_get_table_metadata / bfs_get_data. Args: params (BrowseCatalogInput): - theme_code (str | None): 2-digit theme code, e.g. '15' for Bildung; omit for the theme list…

ParameterTypeDescription
params *

bfs_search_tables

Search for BFS statistical tables by keyword in their titles. Performs a full-text search across all 682+ BFS table titles. Results include table IDs needed for bfs_get_table_metadata and bfs_get_data. Note: First call builds a catalog (~682 API requests). Subsequent calls within 1 hour use the cached catalog and are instant. Args: params (SearchTablesInput): - query (str): Search keywords, e.g. 'Lehrkräfte', 'Schüler Kanton' - theme_code (Optional[str]): Filter by theme, e.g. '15' - lang (str): Language for table titles…

ParameterTypeDescription
params *

bfs_get_table_metadata

Get metadata for a BFS table: title, variables, and available filter values. Essential step before calling bfs_get_data. Returns all dimension variables with their codes and value labels needed to construct data queries. Args: params (GetTableMetadataInput): - table_id (str): BFS table ID, e.g. 'px-x-1504000000_173' - lang (str): Language for labels Returns: str: JSON with table title, source, update date, and all variables with their codes and value options. Use variable codes in bfs_get_data filters. Example output…

ParameterTypeDescription
params *

bfs_get_data

Query statistical data from a BFS table with optional filters. Fetches actual data values from a STAT-TAB table. Always call bfs_get_table_metadata first to understand available variables and values. Args: params (GetDataInput): - table_id (str): BFS table ID - filters (Optional[list]): Dimension filters to narrow results. Each filter: {"code": "VariableCode", "values": ["val1", "val2"]} Without filters, all data is returned (may be very large). - lang (str): Language for labels - max_rows (int):…

ParameterTypeDescription
params *

bfs_education_stats

Retrieve Swiss education statistics — convenience tool for Schulamt context. Provides direct access to key education datasets without needing to know table IDs or variable codes. Covers teachers, students, enrollment scenarios, and scholarship data, optionally filtered by canton. Args: params (GetEducationStatsInput): - topic (str): One of: 'teachers', 'students', 'scenarios', 'scholarships' - canton (Optional[str]): Canton name, e.g. 'Zürich'. None = all cantons. - lang (str): Language code Returns: DataTableResult…

ParameterTypeDescription
params *

bfs_population

Retrieve Swiss population statistics by region, year, and breakdown. Accesses the core BFS population dataset (ständige Wohnbevölkerung) with flexible filtering by canton/municipality, year, age, and gender. Critical for school space planning and demographic projections. Args: params (GetPopulationInput): - region (str): 'Schweiz', or canton name like 'Zürich' - year (Optional[str]): Year filter, e.g. '2024' - breakdown (str): 'total', 'age', or 'gender' Returns: str: JSON with population figures for the selected reg…

ParameterTypeDescription
params *

bfs_compare_cantons

Compare a BFS statistical indicator across multiple Swiss cantons. Designed for KI-Fachgruppe demos and benchmarking. Fetches the same dataset for multiple cantons simultaneously, enabling direct comparison. Args: params (CompareCantonsInput): - table_id (str): BFS table ID to query - canton_values (list[str]): Canton value codes to compare. Use '0' for Switzerland total, '1' for Zürich, '2' for Bern, etc. Get codes via bfs_get_table_metadata on any canton-level table. - additional_filters (Optional[list]):…

ParameterTypeDescription
params *

lookup_commune

Resolve a Swiss commune by name or BFS number, as of a given date. The BFS commune number is the portfolio's join key. This tool returns the official register entry — BFS number, name, canton, validity dates and the stable LINDAS URI — for a commune as it existed on `valid_at_date`. Args: params (LookupCommuneInput): - name_or_bfs_number (str): name/substring or BFS number - valid_at_date (str): ISO date; commune state as of this date Returns: LookupCommuneResult with matching `communes` (BFS number, canton, validity, L…

ParameterTypeDescription
params *

resolve_historical_commune

Map a historical BFS commune number onto today's number(s). This is the core value of the reference layer: when old statistics are keyed on a BFS number that has since been merged or renamed, this tool returns which of today's commune(s) that number resolves to, plus the mutation path (fusions/renamings with dates). Use `resolves_to` to re-key (umschlüsseln) old figures onto the current municipal division. Args: params (ResolveHistoricalCommuneInput): - bfs_number (int): historical BFS number - from_date (str): ISO date the old data be…

ParameterTypeDescription
params *

list_communes

List all communes of a canton, as of a given date. Canton membership is derived from the snapshot's Parent chain (commune → district → canton), so this reflects the official division on `valid_at_date`. Each entry carries its BFS number and LINDAS URI. Args: params (ListCommunesInput): - canton (str): abbreviation ('ZH') or name ('Zürich') - valid_at_date (str): ISO date; default today Returns: ListCommunesResult with the canton's `communes`, sorted by BFS number. On error, `error` and `hint` are set.

ParameterTypeDescription
params *

search_historical_series

Search long-run historical time series (HSSO) by topic. Historical Statistics of Switzerland provides long-run series (roughly 19th–20th century) as static XLSX tables. This tool searches the table catalogue by keyword and returns each match with its page and a stable XLSX download URL. Licence: HSSO is CC BY-NC-SA 3.0 — attribution required, NonCommercial. Every response carries that notice in `licence_note`. Args: params (SearchHistoricalSeriesInput): - topic (str): keyword(s); all must match the title - period (str): optiona…

ParameterTypeDescription
params *

bfs_construction_activity

Yearly new buildings and new dwellings for a commune, with room-size mix. Returns the consolidated official annual construction statistics (BFS STAT-TAB theme 09) for one commune: newly built buildings with dwellings (px-x-0904030000_106) and newly built dwellings broken down by number of rooms (px-x-0904030000_105), as a per-year series from `since_year`. Note: this is the *consolidated official yearly* statistic. For up-to-date building-register states and the construction pipeline (Baugesuche / Bauvorhaben), see the `swiss-housing-mcp` server — the overlap is…

ParameterTypeDescription
params *

bfs_construction_investment

Yearly building investment and Arbeitsvorrat for a region/canton/commune. Returns building investment (Bauinvestitionen, current year) alongside the Arbeitsvorrat (work on hand for the following year) from BFS STAT-TAB px-x-0904010000_205, as a per-year series from `since_year`. The Arbeitsvorrat is the monetary leading indicator: it signals next year's construction volume before it is realised. Args: params (ConstructionInvestmentInput): - level (str): 'grossregion', 'kanton', or 'gemeinde' - code (str): region/canton/commune code matc…

ParameterTypeDescription
params *

bfs_price_index

Swiss price indices not carried by STAT-TAB: Baupreisindex & IMPI. - `baupreisindex`: the construction price index — returns the national semi-annual index series (Schweiz, Baugewerbe Total), parsed from the BFS DAM XLSX selected via opendata.swiss (CKAN) metadata. - `impi`: the residential property price index — BFS publishes this only as PDF/HTML, so this returns the official source links plus an explicit limitation rather than parsed values. Data flows through opendata.swiss (CKAN), which rejects default User-Agents with HTTP 403; a custom User-…

ParameterTypeDescription
params *