Skip to main content
Glama
CBS Open Data MCP Server

CBS Open Data MCP Server

by Tdh25

CBS Open Data MCP Server

Een Model Context Protocol (MCP) server voor de CBS Open Data OData API.

Hiermee kunnen AI-assistenten (GitHub Copilot, Claude Desktop, etc.) direct CBS-statistieken opvragen, filteren en verkennen.

Beschikbare tools

Tool

Omschrijving

query_datasets

Zoek datasets op titel of omschrijving met OData-filtering

get_dataset_info

Haal metadata op voor één specifieke dataset

get_dimensions

Haal dimensies en hun labelwaarden op voor een dataset

get_dimension_values

Haal alle waarden op voor een specifieke dimensie

get_measure_codes

Haal measure-definities op (de beschikbare meetkolommen)

get_observations

Haal alle observaties op met automatische paginering en label-resolutie

query_observations

Geavanceerde OData-query op observaties

get_catalogs

Haal alle beschikbare CBS-catalogi op

get_metadata

Haal het EDM-metadataschema op als XML

Related MCP server: Dataverse MCP Server

Vereisten

  • Python 3.10 of hoger

  • uv (aanbevolen) of pip

Installatie

Met uv (aanbevolen)

git clone https://github.com/TdH25/cbs-open-data-mcp.git
cd cbs-open-data-mcp
uv sync

Met pip

git clone https://github.com/TdH25/cbs-open-data-mcp.git
cd cbs-open-data-mcp
pip install httpx "mcp>=0.9.1"

MCP-server instellen

VS Code (GitHub Copilot)

Voeg het volgende toe aan .vscode/mcp.json in je workspace (of gebruik het meegeleverde bestand):

{
  "servers": {
    "cbs-open-data": {
      "type": "stdio",
      "command": "uv",
      "args": [
        "run",
        "--no-project",
        "--isolated",
        "--link-mode=copy",
        "--with", "mcp",
        "--with", "httpx",
        "python",
        "-m", "src.cbs_open_data_mcp_server"
      ]
    }
  }
}

Claude Desktop

Voeg het volgende toe aan claude_desktop_config.json:

{
  "mcpServers": {
    "cbs-open-data": {
      "command": "uv",
      "args": [
        "run",
        "--directory", "/pad/naar/cbs-open-data-mcp",
        "python",
        "-m", "src.cbs_open_data_mcp_server"
      ]
    }
  }
}

Of installeer het pakket eerst (pip install . of uv sync) en gebruik dan het meegeleverde commando rechtstreeks:

{
  "mcpServers": {
    "cbs-open-data": {
      "command": "cbs-open-data-mcp"
    }
  }
}

Gebruik in de chat

Na installatie kun je hem gelijk gebruiken: stel in Copilot Chat of Claude een vraag over CBS-statistieken. De AI kiest zelf de juiste tools en werkwijze - mede dankzij meegeleverde copilot-instructies.

Voorbeeldprompts:

  • "Welke datasets heeft CBS over aardgasverbruik?"

  • "Haal de inwoners per provincie op uit 03759ned (meest recente jaar, totaal) en toon als tabel."

  • "Toon de CO₂-uitstoot per sector over de afgelopen 5 jaar in een grafiek."

  • "Haal dataset 80030ned op in een nieuwe Notebook en plot de totale elektriciteitsproductie per jaar per energiedrager in een stacked area chart met plotly."

Example screenshot

Bekende beperkingen

  • SSL-verificatie uitgeschakeld — de CBS API heeft een certificaatprobleem met de standaard CA-bundle. verify=False is standaard ingesteld.

  • Trage API — de CBS OData API kan traag reageren; timeout is 60 seconden met 3 retry-pogingen.

  • resolve_labels — label-resolutie maakt N+2 extra API-calls (N = aantal dimensies). Bij grote datasets kan dit merkbaar zijn.

Tests

uv run python -m unittest tests.test_cbs_open_data_client -v

Verwant project

mcp-cbs-cijfers-open-data van David Stotijn — een MCP-server voor dezelfde CBS Open Data API, geschreven in Go. Dit project is onafhankelijk ontwikkeld in Python en voegt onder andere automatische paginering, label-resolutie en measure-definitie-ondersteuning toe.

Licentie

MIT — zie LICENSE.

Available Tools

9 tools
get_catalogsA

Fetch all available CBS catalogs.

Returns: dict[str, Any]: Count and list of catalogs.

Inputs: no named parameters. Returns: object

get_dataset_infoA

Fetch metadata for a single specific dataset.

Returns title, description, status, last modification date, and more. Use this to quickly check whether a dataset is relevant.

Args: catalog: Catalog identifier. dataset: Dataset identifier (e.g. '85523NED').

Returns: dict[str, Any]: Dataset metadata.

Inputs: catalog, dataset. Returns: object

get_dimensionsA

Fetch all dimensions for a dataset.

Args: catalog: Catalog identifier. dataset: Dataset identifier.

Returns: dict[str, Any]: Table of dimensions and labels per dimension.

Inputs: catalog, dataset. Returns: object

get_dimension_valuesA

Fetch values for a specific dimension.

WARNING: this endpoint returns 404 on most CBS datasets. Prefer get_dimensions(), which already resolves all dimension codes and labels via the reliable {dim}Codes endpoints.

Args: catalog: Catalog identifier. dataset: Dataset identifier. dimension: Dimension identifier. select: OData $select. filter: Additional OData $filter. orderby: OData $orderby. top: OData $top.

Returns: dict[str, Any]: Count and dimension values.

Inputs: top, filter, select, catalog, +3 more. Returns: object

get_measure_codesA

Fetch measure code definitions for a dataset.

Measures are the columns containing actual measurement values in observations. Each measure has an Identifier (code) and Title (label).

Args: catalog: Catalog identifier. dataset: Dataset identifier.

Returns: dict[str, Any]: Count and list of measure codes.

Inputs: catalog, dataset. Returns: object

get_metadataA

Fetch the OData metadata document (EDM schema).

Note: This returns the catalog-wide schema, not dataset-specific metadata. Use get_dataset_info() for metadata of a single dataset.

Returns: dict[str, str]: Metadata as an XML string.

Inputs: no named parameters. Returns: object

get_observationsA

Fetch observations with automatic pagination.

Automatically follows @odata.nextLink to retrieve all pages. With resolve_labels=True, dimension and measure codes are replaced with human-readable labels.

Args: catalog: Catalog identifier. dataset: Dataset identifier. filters: Dimension filters (key=dimension, value=code). paginate: Fetch all pages (True) or just one page (False). resolve_labels: Replace codes with labels (True) or keep raw codes (False, faster). limit: Maximum number of observations (safety limit).

Returns: dict[str, Any]: Observation result.

Inputs: limit, catalog, dataset, filters, +2 more. Returns: object

query_datasetsA

Search datasets with OData filtering, sorting, and pagination.

RECOMMENDATION: use filter with contains() instead of search. The CBS $search often returns irrelevant results. Example: filter="contains(Title,'warmte')" or filter="contains(Title,'energie') and contains(Title,'verbruik')".

Args: catalog: Catalog identifier, typically CBS. select: OData $select. filter: OData $filter -- use contains() for title search. orderby: OData $orderby. top: OData $top. skip: OData $skip. count: OData $count. search: OData $search (UNRELIABLE -- use filter instead). expand: OData $expand. exclude_discontinued: Prepend a default filter to exclude discontinued datasets.

Returns: dict[str, Any]: Query info and dataset results.

Inputs: top, skip, count, expand, +6 more. Returns: object

query_observationsB

Query observations with advanced OData options.

Args: catalog: Catalog identifier. dataset: Dataset identifier. select: OData $select. filter: OData $filter. orderby: OData $orderby. top: OData $top. skip: OData $skip. count: OData $count. search: OData $search. expand: OData $expand.

Returns: dict[str, Any]: Query info and observation results.

Inputs: top, skip, count, expand, +6 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 9 tools

    Disambiguation3/5

    Tools generally target distinct resources, but there is clear overlap between get_dimensions and get_dimension_values (the latter is explicitly discouraged), and between get_observations and query_observations which both fetch observations with different options. Descriptions help clarify, but an agent could still be confused about which to use.

    Naming Consistency4/5

    Most tools follow a get_* verb_noun pattern (get_catalogs, get_metadata, get_dimensions). Two tools use query_* (query_datasets, query_observations), which is a minor deviation but still consistent in style. Names are readable and predictable.

    Tool Count5/5

    With 9 tools, the server is well-scoped for a statistical data API. Each tool serves a distinct aspect of data access: catalogs, metadata, dataset search, dimensions, observations, and measures, with no unnecessary bloat.

    Completeness4/5

    The core workflow is covered: discover catalogs, search datasets, get dataset info, fetch dimensions, observations, and measure codes. Minor gaps include the non-functional get_dimension_values (mitigated by get_dimensions) and no explicit way to download a full dataset in one call, but agents can compose queries to achieve this.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      A model Context Protocol (MCP) server that provides comprehensive OECD statistics through the SDMX API, supporting AI assistants and chatbots to query OECD datasets in areas such as economy, health, education, and environment.
      9
      2
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables CRUD operations and querying on Microsoft Dataverse through natural language.
      7 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      A Model Context Protocol server that exposes the Dominican Republic's open government data (datos.gob.do) as tools consumable by any AI assistant.
      23
      44 PyPI
      3
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A Model Context Protocol server that connects AI assistants to UNESCO Institute for Statistics data, enabling natural language search, retrieval, and comparison of indicators across countries.
      13
      3
      MIT