cbs-statistics-mcp-server

TCLUBNL/cbs-statistics-mcp-server

3.1

If you are the rightful owner of cbs-statistics-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

Unified data gateway for CBS Open Data APIs, providing access to a wide range of datasets including demographics, economics, and labor statistics.

📊 CBS Statistics MCP Server

Unified data gateway for CBS Open Data APIs (demographics, economics, labor, etc.)

This project implements an MCP (Model Context Protocol) server providing structured access to statistical and demographic data from the Centraal Bureau voor de Statistiek (CBS) of the Netherlands.


🧠 Architecture Overview

Client: Statistics & Demographics MCP Client

  • Lives inside an MCP host (e.g., Claude Desktop)
  • Uses the defined manifest (mcp.json) to understand available tools, resources, and prompts
  • Sends user queries to the CBS MCP Server for structured data retrieval and analysis

Server: CBS Statistics MCP Server (this project)

  • Built using Python (FastAPI)
  • Provides unified access to multiple CBS Open Data APIs through REST endpoints
  • Contains tools (API logic), resources (API definitions), and prompts (analysis templates)
  • Exposes mcp.json for automatic client integration

🌍 APIs Included

APIDescriptionExample Use
CBS Open DataCore API providing structured access to CBS datasetsGeneral data access layer for all submodules
Wijken en BuurtenNeighborhood-level statistics on demographics, population, housingAnalyze potential store locations or population density by postal code
BevolkingsstatistiekenNational and regional population data (size, growth, migration)Understand population trends for market expansion
Economische IndicatorenEconomic performance data (income, consumption, GDP per region)Assess purchasing power or economic strength of a region
ArbeidsmarktLabor market indicators (employment rate, sectoral distribution)Evaluate workforce availability and regional employment stability

🚀 Quick Start

1. Clone the Repository

git clone https://github.com/TCLUBNL/cbs-statistics-mcp-server.git
cd cbs-statistics-mcp-server

2. Create Virtual Environment

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Run the Server

uvicorn server.main:app --reload --port 4001

The server will start at http://localhost:4001

5. Test the API

curl http://localhost:4001/

🔌 Connect to Claude Desktop

  1. Open Claude Desktop settings
  2. Navigate to Model Context ProtocolAdd Server
  3. Enter server URL: http://localhost:4001/mcp.json
  4. Save and restart Claude Desktop

Claude will automatically load all CBS Statistics tools, resources, and prompts.


📡 API Endpoints

EndpointDescription
GET /Server status and endpoint list
GET /mcp.jsonMCP manifest for client integration
GET /api/neighborhood/{code}Fetch neighborhood statistics by CBS code
GET /api/population?region={name}Get population data (national or regional)
GET /api/economy?region={name}Get economic indicators
GET /api/labor?region={name}Get labor market data
GET /api/search?query={keyword}Search CBS datasets by keyword

💼 Business Use Cases

Retail Expansion

A retail chain can identify optimal store locations by:

  1. Retrieving demographic and economic data per neighborhood
  2. Filtering areas with high population density and income levels
  3. Cross-referencing employment rates and economic growth
  4. Generating human-readable insights via MCP prompts

Urban Planning

Government agencies can use the data for:

  • Population trend analysis
  • Infrastructure planning based on demographic shifts
  • Economic development zone identification

Market Research

Businesses can leverage the data for:

  • Target market identification
  • Competitive analysis by region
  • Consumer purchasing power assessment

🏗️ Project Structure

cbs-statistics-mcp-server/
│
├── mcp.json                           # MCP manifest (root of the system)
│
├── server/
│   ├── main.py                        # FastAPI entry point
│   │
│   ├── tools/                         # Individual logic modules (Python)
│   │   ├── get_neighborhood_stats.py
│   │   ├── get_population_data.py
│   │   ├── get_economic_indicators.py
│   │   ├── get_labor_market_data.py
│   │   └── search_cbs_datasets.py
│   │
│   ├── resources/                     # YAML definitions for each CBS dataset
│   │   ├── cbs_open_data.yaml
│   │   ├── wijken_buurten.yaml
│   │   ├── bevolkingsstatistieken.yaml
│   │   ├── economische_indicatoren.yaml
│   │   └── arbeidsmarkt.yaml
│   │
│   ├── prompts/                       # Prompt templates for MCP client
│   │   ├── analyze_neighborhood_potential.md
│   │   ├── find_optimal_store_location.md
│   │   ├── demographic_summary.md
│   │   └── compare_economic_zones.md
│   │
│   └── utils/                         # Optional helper functions
│
├── requirements.txt                   # Python dependencies
├── .gitignore                         # Git ignore rules
└── README.md                          # This file

🧠 Example MCP Workflow

  1. Claude Desktop (client) connects to http://localhost:4001/mcp.json
  2. Claude loads all available tools, resources, and prompts
  3. User asks:

    "Find promising neighborhoods near Utrecht for a new store."

  4. MCP server:
    • Queries Wijken en Buurten and Economische Indicatoren datasets
    • Applies the find_optimal_store_location.md prompt logic
    • Returns data-rich insights with tables and summaries

🪄 Technology Stack

  • FastAPI - Modern Python web framework for APIs
  • Requests - HTTP library for CBS API calls
  • Pandas - Data manipulation (optional enhancement)
  • PyYAML - YAML configuration parsing
  • Uvicorn - ASGI server for FastAPI

📚 CBS Data Sources

All data comes from CBS Open Data Portal:


🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


📄 License

This project is licensed under the MIT License.


🔗 Links


Built with ❤️ for data-driven decision making