Skip to main content
Glama
BDL MCP Server

BDL MCP Server

by dvvbk

BDL MCP Server

MCP (Model Context Protocol) Server for Bank Danych Lokalnych (BDL) API running on Cloudflare Workers.

Overview

This server exposes the Polish Central Statistical Office (GUS) Local Data Bank API as MCP tools, allowing AI assistants like Claude to query statistical data about Poland's territorial units, demographics, economy, and more.

Related MCP server: mcp-csu

Features

  • 🚀 Runs on Cloudflare Workers (edge computing, global distribution)

  • 📊 Full BDL API coverage with 25+ tools

  • 🌐 Supports both Polish and English language responses

  • 🔄 SSE and Streamable HTTP transport

  • ✅ Type-safe with TypeScript and Zod validation

Available Tools

Aggregates

  • get_aggregates - List aggregation levels (voivodeship, county, commune, etc.)

  • get_aggregate - Get specific aggregation level details

Attributes

  • get_attributes - List data attributes/flags

  • get_attribute - Get specific attribute details

Levels

  • get_levels - List territorial levels

  • get_level - Get specific level details

Measures

  • get_measures - List measurement units

  • get_measure - Get specific measure details

Subjects (Statistical Categories)

  • get_subjects - List statistical subjects/categories

  • get_subject - Get specific subject details

  • search_subjects - Search subjects by name

Units (Territorial Divisions)

  • get_units - List territorial units (voivodeships, counties, communes)

  • get_unit - Get specific unit by TERYT code

  • search_units - Search units by name

Localities

  • get_localities - List localities (cities, towns, villages)

  • get_locality - Get specific locality details

  • search_localities - Search localities by name

Variables (Statistical Indicators)

  • get_variables - List statistical variables

  • get_variable - Get variable details including available years

  • search_variables - Search variables by name

Data

  • get_data_by_variable - Get data for a variable across units

  • get_data_by_unit - Get data for a unit across variables

  • get_locality_data_by_variable - Get locality-level data by variable

  • get_locality_data_by_unit - Get locality-level data by unit

Years

  • get_years - List available years in database

  • get_year - Get specific year details

Meta

  • get_api_version - Get API version information

Installation

Prerequisites

  • Node.js 18+

  • Cloudflare account

  • Wrangler CLI

Setup

# Clone or copy the project
cd bdl-mcp-server

# Install dependencies
npm install

# Run locally
npm run dev

# Deploy to Cloudflare Workers
npm run deploy

Configuration

Edit wrangler.toml to customize:

[vars]
BDL_API_BASE_URL = "https://bdl.stat.gov.pl/api/v1"
DEFAULT_LANGUAGE = "pl"  # or "en"

Usage

Connecting with Claude Desktop

Add to your Claude Desktop config (claude_desktop_config.json):

{
  "mcpServers": {
    "bdl": {
      "url": "https://your-worker.your-subdomain.workers.dev/sse"
    }
  }
}

Connecting with MCP Inspector

  1. Start the server locally: npm run dev

  2. Open MCP Inspector at http://localhost:5173

  3. Connect to http://localhost:8787/sse

Direct API Usage

Health Check:

curl https://your-worker.workers.dev/

MCP Request (Streamable HTTP):

curl -X POST https://your-worker.workers.dev/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list"
  }'

Example Queries

Get Population Data for Warsaw

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search_units",
    "arguments": {
      "name": "Warszawa",
      "lang": "en"
    }
  }
}

Get Available Statistical Variables for Demographics

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "search_variables",
    "arguments": {
      "name": "population",
      "lang": "en"
    }
  }
}

Get Data for a Specific Variable

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "get_data_by_variable",
    "arguments": {
      "varId": 72305,
      "unitLevel": 2,
      "year": 2023,
      "lang": "en"
    }
  }
}

Project Structure

bdl-mcp-server/
├── src/
│   ├── index.ts          # Cloudflare Workers entry point
│   ├── mcp-server.ts     # MCP protocol implementation
│   ├── tools.ts          # Tool definitions with Zod schemas
│   ├── tool-handler.ts   # Tool execution logic
│   ├── bdl-client.ts     # BDL API client
│   └── types.ts          # TypeScript types from Swagger
├── package.json
├── tsconfig.json
├── wrangler.toml         # Cloudflare Workers config
└── README.md

Development

# Start development server with hot reload
npm run dev

# Type check
npm run build

# Deploy to production
npm run deploy

API Reference

This server implements the Model Context Protocol specification, exposing the BDL API through MCP tools.

Endpoints

  • GET / - Health check and server info

  • GET /sse - SSE connection for MCP clients

  • POST /mcp - Streamable HTTP endpoint for JSON-RPC requests

Transport

Supports both:

  • SSE (Server-Sent Events) - For real-time bidirectional communication

  • Streamable HTTP - For request/response style communication

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server providing AI assistants access to Polish public registries (KRS, CEIDG) and statistical data (GUS BDL) for querying companies, sole proprietorships, and regional statistics.
      6
      7
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides AI assistants direct access to 700+ statistical datasets about the Czech Republic, including population, economy, prices, wages, employment, industry, agriculture, trade, tourism, environment, and more.
      12
      2
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      MCP server that provides AI agents with Polish business data tools: identifier validation (NIP, PESEL, REGON, KRS, IBAN), VAT whitelist checks, EU VIES lookups, and NBP exchange rates.
      5
      13 npm
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Local MCP server for querying Polish socioeconomic statistics from the GUS Bank Danych Lokalnych (BDL), letting AI find variables and units and pull data.
      5
      MIT