← Back to search

io.github.malkreide/swiss-statistics-mcp

malkreide Scanned 18d ago

BFS STAT-TAB PxWeb API for official Swiss statistics

D
55.9 / 100

Versions

0.2.3latest
first seen Jun 30, 2026
PermissionsTool SafetyAuthAnnotationsCode QualityStabilitySpecVuln HistoryAuthorTransparencyCommunity

Tools 15

bfs_browse_catalog
annotations: none low

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 - lang (str): Language code ('de', 'fr', 'it', 'en') - limit (int): Max tables to return (theme mode; default 20) Returns: BrowseCatalogResult. `mode='themes'` populates `themes`; `mode='tables'` populates `tables` plus theme metadata. On error, `error`/`hint` are set.

params BrowseCatalogInput
bfs_search_tables
annotations: none low

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 - limit (int): Max results (default 10) Returns: SearchTablesResult with matching tables. On error, `error` and `hint` are set and `results` is None.

params SearchTablesInput
bfs_get_table_metadata
annotations: none low

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 structure: { "title": "Lehrkräfte nach Schuljahr, Kanton...", "variables": [ { "code": "Schuljahr", "label": "Schuljahr", "n_values": 14, "values": [{"code": "0", "label": "2010/11"}, ...] } ] }

params GetTableMetadataInput
bfs_get_data
annotations: none low

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): Safety limit on returned rows (default 500) Returns: DataTableResult with `dimensions`, `rows`, plus `truncated`, `rows_total`, `rows_returned` for machine-readable capping. On error, `error` and `hint` are set.

params GetDataInput
bfs_education_stats
annotations: none low

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 with `topic`, `topic_description`, `canton_filter` on success, plus the data table fields. On error, `error` and `hint` are set.

params GetEducationStatsInput
bfs_population
annotations: none low

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 region and breakdown.

params GetPopulationInput
bfs_compare_cantons
annotations: none low

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]): Extra dimension filters - lang (str): Language code Returns: str: JSON with data for all selected cantons side by side. Example use case: Compare teacher-to-student ratios across ZH, BE, LU, CH total: canton_values=['0', '1', '2', '3']

params CompareCantonsInput
bfs_featured_datasets
annotations: none low

Return a curated list of high-value BFS datasets for Schulamt and public administration. Provides a shortlist of the most relevant datasets for education planning, demographic analysis, and political context — ideal as a starting point. Args: params (ListThemesInput): - lang (str): Language code Returns: FeaturedDatasetsResult with curated table IDs, titles, themes, and recommended use cases.

params ListThemesInput
lookup_commune
annotations: none low

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, LINDAS URI). On error, `error` and `hint` are set.

params LookupCommuneInput
resolve_historical_commune
annotations: none low

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 belongs to - to_date (str): ISO target date (default today) Returns: ResolveHistoricalCommuneResult with `resolves_to` (today's BFS number/name/LINDAS URI) and `mutation_path`. On error, `error`/`hint`.

params ResolveHistoricalCommuneInput
list_communes
annotations: none low

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.

params ListCommunesInput
search_historical_series
annotations: none low

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): optional period hint (informational only) Returns: SearchHistoricalSeriesResult with matching `series` (code, title, page URL, XLSX URL). On error, `error` and `hint` are set.

params SearchHistoricalSeriesInput
bfs_construction_activity
annotations: none low

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 deliberate so the two sources can be cross-validated. Args: params (ConstructionActivityInput): - municipality_bfs (int): BFS commune number, e.g. 261 (Zürich) - since_year (int): earliest year, inclusive (default 2015) Returns: ConstructionActivityResult with a `years` series (new_buildings, new_dwellings, dwellings_by_rooms). On error, `error`/`hint` are set.

params ConstructionActivityInput
bfs_construction_investment
annotations: none low

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 matching `level` - since_year (int): earliest year, inclusive (default 2015) Returns: ConstructionInvestmentResult with a `years` series (investment, work_on_hand) in 1000 CHF. On error, `error`/`hint` are set.

params ConstructionInvestmentInput
bfs_price_index
annotations: none low

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-Agent is always sent. Results are cached for 24h. Args: params (PriceIndexInput): - index (str): 'baupreisindex' or 'impi' - since_year (int | None): optional earliest year to include Returns: PriceIndexResult with `series` (baupreisindex) or `source_links` (impi). On error, `error`/`hint` are set.

params PriceIndexInput

Permissions 4

env_vars low
Server uses env_vars capabilities via: os.environ
network medium
Server uses network capabilities via: httpx, urllib
filesystem low
Server uses filesystem capabilities via: open(), os, pathlib, shutil, tempfile
shell high
Server uses shell capabilities via: subprocess

Scan Findings 46

low
Tool 'bfs_browse_catalog' has no annotations annotation_checker · 100%
low
Tool 'bfs_search_tables' has no annotations annotation_checker · 100%
low
Tool 'bfs_get_table_metadata' has no annotations annotation_checker · 100%
low
Tool 'bfs_get_data' has no annotations annotation_checker · 100%
low
Tool 'bfs_education_stats' has no annotations annotation_checker · 100%
low
Tool 'bfs_population' has no annotations annotation_checker · 100%
low
Tool 'bfs_compare_cantons' has no annotations annotation_checker · 100%
low
Tool 'bfs_featured_datasets' has no annotations annotation_checker · 100%
low
Tool 'lookup_commune' has no annotations annotation_checker · 100%
low
Tool 'resolve_historical_commune' has no annotations annotation_checker · 100%
low
Tool 'list_communes' has no annotations annotation_checker · 100%
low
Tool 'search_historical_series' has no annotations annotation_checker · 100%
low
Tool 'bfs_construction_activity' has no annotations annotation_checker · 100%
low
Tool 'bfs_construction_investment' has no annotations annotation_checker · 100%
low
Tool 'bfs_price_index' has no annotations annotation_checker · 100%
high
Remote transport without authentication auth_checker · 70%
info
Sandbox failed to start for behavioral verification behavioral_verifier · 100%
medium
Vulnerable dependency: pydantic@2.0.0 (GHSA-mr82-8j83-vxmv) dependency_analyzer · 95%
medium
Vulnerable dependency: pydantic@2.0.0 (PYSEC-2026-1812) dependency_analyzer · 95%
info
pyproject.toml metadata manifest_parser · 100%
info
Tool: bfs_browse_catalog manifest_parser · 90%
info
Tool: bfs_search_tables manifest_parser · 90%
info
Tool: bfs_get_table_metadata manifest_parser · 90%
info
Tool: bfs_get_data manifest_parser · 90%
info
Tool: bfs_education_stats manifest_parser · 90%
info
Tool: bfs_population manifest_parser · 90%
info
Tool: bfs_compare_cantons manifest_parser · 90%
info
Tool: bfs_featured_datasets manifest_parser · 90%
info
Tool: lookup_commune manifest_parser · 90%
info
Tool: resolve_historical_commune manifest_parser · 90%
info
Tool: list_communes manifest_parser · 90%
info
Tool: search_historical_series manifest_parser · 90%
info
Tool: bfs_construction_activity manifest_parser · 90%
info
Tool: bfs_construction_investment manifest_parser · 90%
info
Tool: bfs_price_index manifest_parser · 90%
info
Transport: streamable-http manifest_parser · 80%
info
Required env vars (10) manifest_parser · 80%
info
Sandbox failed to start for output poisoning scan output_poisoning · 100%
medium
Permission: network access detected permission_analyzer · 90%
low
Permission: filesystem access detected permission_analyzer · 90%
high
Permission: shell access detected permission_analyzer · 95%
low
Permission: env_vars access detected permission_analyzer · 90%
critical
Tool poisoning in 'bfs_search_tables': Cross-tool prerequisite: 'first call/use' poisoning · 85%
critical
Tool poisoning in 'bfs_get_data': Directive language: 'always' poisoning · 85%
info
No dependency files found for SBOM generation sbom_generator · 100%
medium
No build provenance detected (SLSA L0) slsa_assessor · 90%