centralbank-data 0.8.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. centralbank_data-0.8.1/.dockerignore +14 -0
  2. centralbank_data-0.8.1/.github/workflows/ci.yml +35 -0
  3. centralbank_data-0.8.1/.github/workflows/docker.yml +64 -0
  4. centralbank_data-0.8.1/.github/workflows/pypi.yml +34 -0
  5. centralbank_data-0.8.1/.github/workflows/release.yml +66 -0
  6. centralbank_data-0.8.1/.gitignore +14 -0
  7. centralbank_data-0.8.1/.public-source.toml +3 -0
  8. centralbank_data-0.8.1/AGENTS.md +16 -0
  9. centralbank_data-0.8.1/CHANGELOG.md +34 -0
  10. centralbank_data-0.8.1/CONTRIBUTING.md +12 -0
  11. centralbank_data-0.8.1/Dockerfile +32 -0
  12. centralbank_data-0.8.1/LICENSE +171 -0
  13. centralbank_data-0.8.1/Makefile +19 -0
  14. centralbank_data-0.8.1/PKG-INFO +107 -0
  15. centralbank_data-0.8.1/README.md +73 -0
  16. centralbank_data-0.8.1/SECURITY.md +11 -0
  17. centralbank_data-0.8.1/docs/CENTRAL_BANKS.md +139 -0
  18. centralbank_data-0.8.1/docs/DESIGN.md +252 -0
  19. centralbank_data-0.8.1/docs/PERMISSIONS.md +32 -0
  20. centralbank_data-0.8.1/docs/PROVIDERS.md +27 -0
  21. centralbank_data-0.8.1/pyproject.toml +76 -0
  22. centralbank_data-0.8.1/src/centralbank_data/__init__.py +32 -0
  23. centralbank_data-0.8.1/src/centralbank_data/cache.py +709 -0
  24. centralbank_data-0.8.1/src/centralbank_data/cli/__init__.py +1 -0
  25. centralbank_data-0.8.1/src/centralbank_data/cli/main.py +589 -0
  26. centralbank_data-0.8.1/src/centralbank_data/errors.py +99 -0
  27. centralbank_data-0.8.1/src/centralbank_data/indicators.py +514 -0
  28. centralbank_data-0.8.1/src/centralbank_data/mcp/__init__.py +1 -0
  29. centralbank_data-0.8.1/src/centralbank_data/mcp/schemas.py +180 -0
  30. centralbank_data-0.8.1/src/centralbank_data/mcp/server.py +1200 -0
  31. centralbank_data-0.8.1/src/centralbank_data/models.py +324 -0
  32. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/__init__.py +1 -0
  33. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/bbk.toml +49 -0
  34. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/bde.toml +44 -0
  35. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/bdp.toml +36 -0
  36. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/bis.toml +101 -0
  37. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/boe.toml +60 -0
  38. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/ecb.toml +760 -0
  39. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/estat.toml +39 -0
  40. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/nationalbanken.toml +20 -0
  41. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/nb.toml +63 -0
  42. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/nbb.toml +37 -0
  43. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/riksbank.toml +36 -0
  44. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/snb.toml +52 -0
  45. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/supervisory_releases.toml +275 -0
  46. centralbank_data-0.8.1/src/centralbank_data/provider_definitions/supervisory_units.toml +108 -0
  47. centralbank_data-0.8.1/src/centralbank_data/providers/__init__.py +1 -0
  48. centralbank_data-0.8.1/src/centralbank_data/providers/base.py +91 -0
  49. centralbank_data-0.8.1/src/centralbank_data/providers/bde.py +411 -0
  50. centralbank_data-0.8.1/src/centralbank_data/providers/bdp.py +444 -0
  51. centralbank_data-0.8.1/src/centralbank_data/providers/boe.py +270 -0
  52. centralbank_data-0.8.1/src/centralbank_data/providers/ecb.py +87 -0
  53. centralbank_data-0.8.1/src/centralbank_data/providers/nationalbanken.py +277 -0
  54. centralbank_data-0.8.1/src/centralbank_data/providers/registry.py +134 -0
  55. centralbank_data-0.8.1/src/centralbank_data/providers/riksbank.py +218 -0
  56. centralbank_data-0.8.1/src/centralbank_data/providers/sdmx_engine.py +776 -0
  57. centralbank_data-0.8.1/src/centralbank_data/providers/snb.py +304 -0
  58. centralbank_data-0.8.1/src/centralbank_data/revalidator.py +146 -0
  59. centralbank_data-0.8.1/src/centralbank_data/service.py +732 -0
  60. centralbank_data-0.8.1/src/centralbank_data/supervisory/__init__.py +34 -0
  61. centralbank_data-0.8.1/src/centralbank_data/supervisory/background.py +187 -0
  62. centralbank_data-0.8.1/src/centralbank_data/supervisory/ingest.py +1161 -0
  63. centralbank_data-0.8.1/src/centralbank_data/supervisory/manifest.py +91 -0
  64. centralbank_data-0.8.1/src/centralbank_data/supervisory/models.py +246 -0
  65. centralbank_data-0.8.1/src/centralbank_data/supervisory/service.py +301 -0
  66. centralbank_data-0.8.1/src/centralbank_data/supervisory/store.py +2152 -0
  67. centralbank_data-0.8.1/src/centralbank_data/supervisory/xlsx.py +202 -0
  68. centralbank_data-0.8.1/src/centralbank_data/telemetry.py +108 -0
  69. centralbank_data-0.8.1/src/centralbank_data/transport.py +507 -0
  70. centralbank_data-0.8.1/surface.json +35 -0
  71. centralbank_data-0.8.1/tests/__init__.py +1 -0
  72. centralbank_data-0.8.1/tests/conftest.py +256 -0
  73. centralbank_data-0.8.1/tests/test_cache_properties.py +199 -0
  74. centralbank_data-0.8.1/tests/test_cli.py +89 -0
  75. centralbank_data-0.8.1/tests/test_dates_and_models.py +98 -0
  76. centralbank_data-0.8.1/tests/test_e2e.py +886 -0
  77. centralbank_data-0.8.1/tests/test_ecb_contract.py +148 -0
  78. centralbank_data-0.8.1/tests/test_errors.py +26 -0
  79. centralbank_data-0.8.1/tests/test_evals.py +88 -0
  80. centralbank_data-0.8.1/tests/test_iberian_providers.py +222 -0
  81. centralbank_data-0.8.1/tests/test_live_ecb.py +85 -0
  82. centralbank_data-0.8.1/tests/test_mcp_wire.py +178 -0
  83. centralbank_data-0.8.1/tests/test_performance_and_concurrency.py +717 -0
  84. centralbank_data-0.8.1/tests/test_phase2_providers.py +299 -0
  85. centralbank_data-0.8.1/tests/test_phase3_sovereigns.py +172 -0
  86. centralbank_data-0.8.1/tests/test_safety.py +225 -0
  87. centralbank_data-0.8.1/tests/test_supervisory.py +1260 -0
  88. centralbank_data-0.8.1/tests/test_surface_coverage.py +43 -0
  89. centralbank_data-0.8.1/uv.lock +1981 -0
@@ -0,0 +1,14 @@
1
+ .git
2
+ .github
3
+ .venv
4
+ .pytest_cache
5
+ .mypy_cache
6
+ .ruff_cache
7
+ __pycache__
8
+ dist
9
+ tests
10
+ docs
11
+ *.db
12
+ *.db-wal
13
+ *.db-shm
14
+ junit-python.xml
@@ -0,0 +1,35 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_call:
8
+
9
+ jobs:
10
+ check:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: astral-sh/setup-uv@v5
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ matrix.python-version }}
21
+ - name: Sync dependencies
22
+ run: uv sync --extra mcp --extra dev
23
+ - name: Run deterministic checks
24
+ run: make check
25
+ - name: Verify zero-bloat wheel install
26
+ run: |
27
+ uv build --wheel
28
+ uv venv /tmp/wheel-check --python ${{ matrix.python-version }}
29
+ uv pip install --python /tmp/wheel-check/bin/python dist/*.whl
30
+ /tmp/wheel-check/bin/python -c "import centralbank_data, httpx, defusedxml"
31
+ /tmp/wheel-check/bin/python -c "
32
+ import importlib.util
33
+ for mod in ('fastmcp', 'pandas', 'pyarrow', 'lxml'):
34
+ assert importlib.util.find_spec(mod) is None, f'Unexpected dep: {mod}'
35
+ "
@@ -0,0 +1,64 @@
1
+ name: Docker
2
+
3
+ on:
4
+ push:
5
+ tags: ['v*.*.*']
6
+ workflow_dispatch: {}
7
+
8
+ permissions: {}
9
+
10
+ concurrency:
11
+ group: docker-${{ github.ref }}
12
+ cancel-in-progress: false
13
+
14
+ jobs:
15
+ ci:
16
+ uses: ./.github/workflows/ci.yml
17
+ permissions:
18
+ contents: read
19
+
20
+ build-and-push:
21
+ needs: ci
22
+ runs-on: ubuntu-latest
23
+ timeout-minutes: 20
24
+ permissions:
25
+ contents: read
26
+ packages: write
27
+ steps:
28
+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
29
+ with:
30
+ persist-credentials: false
31
+
32
+ - name: Log in to GHCR
33
+ uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4
34
+ with:
35
+ registry: ghcr.io
36
+ username: ${{ github.actor }}
37
+ password: ${{ secrets.GITHUB_TOKEN }}
38
+
39
+ - uses: docker/setup-buildx-action@v3
40
+
41
+ - name: Build and push image
42
+ env:
43
+ DOCKER_BUILDKIT: "1"
44
+ VCS_REF: ${{ github.sha }}
45
+ IMAGE: ghcr.io/${{ github.repository_owner }}/centralbank-data
46
+ run: |
47
+ set -euo pipefail
48
+ VERSION="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
49
+ BUILD_DATE="$(git show -s --format=%cI "$VCS_REF")"
50
+ SHORT_SHA="sha-$(git rev-parse --short=12 "$VCS_REF")"
51
+ TAGS=(--tag "$IMAGE:$SHORT_SHA")
52
+ if [ "${{ github.event_name }}" = push ] && [ "${{ github.ref_type }}" = tag ]; then
53
+ [ "${GITHUB_REF_NAME#v}" = "$VERSION" ] || { echo "tag $GITHUB_REF_NAME != $VERSION" >&2; exit 1; }
54
+ TAGS+=(--tag "$IMAGE:$VERSION" --tag "$IMAGE:latest")
55
+ fi
56
+ docker buildx build --push \
57
+ --platform linux/amd64 \
58
+ --build-arg "VERSION=$VERSION" \
59
+ --build-arg "VCS_REF=$VCS_REF" \
60
+ --build-arg "BUILD_DATE=$BUILD_DATE" \
61
+ --metadata-file /tmp/docker-meta.json \
62
+ "${TAGS[@]}" \
63
+ .
64
+ cat /tmp/docker-meta.json
@@ -0,0 +1,34 @@
1
+ name: PyPI
2
+
3
+ on:
4
+ push:
5
+ tags: ['v*.*.*']
6
+ workflow_dispatch: {}
7
+
8
+ permissions: {}
9
+
10
+ concurrency:
11
+ group: pypi-${{ github.ref }}
12
+ cancel-in-progress: false
13
+
14
+ jobs:
15
+ publish:
16
+ if: github.ref_type == 'tag' && (github.event_name == 'workflow_dispatch' || vars.PYPI_PUBLISH == 'true')
17
+ runs-on: ubuntu-latest
18
+ timeout-minutes: 10
19
+ environment: pypi
20
+ permissions:
21
+ contents: read
22
+ id-token: write
23
+ steps:
24
+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
25
+ with:
26
+ persist-credentials: false
27
+ - uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
28
+ - name: Build
29
+ run: |
30
+ version="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
31
+ [ "${GITHUB_REF_NAME#v}" = "$version" ] || { echo "tag $GITHUB_REF_NAME is not version $version" >&2; exit 1; }
32
+ uv build
33
+ - name: Upload
34
+ run: uv publish --trusted-publishing always --check-url https://pypi.org/simple/
@@ -0,0 +1,66 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ['v*.*.*']
6
+ workflow_dispatch: {}
7
+
8
+ permissions: {}
9
+
10
+ concurrency:
11
+ group: release-${{ github.ref }}
12
+ cancel-in-progress: false
13
+
14
+ jobs:
15
+ released:
16
+ runs-on: ubuntu-latest
17
+ timeout-minutes: 5
18
+ permissions:
19
+ contents: read
20
+ outputs:
21
+ done: ${{ steps.check.outputs.done }}
22
+ steps:
23
+ - id: check
24
+ env:
25
+ GH_TOKEN: ${{ github.token }}
26
+ TAG: ${{ github.ref_name }}
27
+ run: |
28
+ done=false
29
+ if [ "$GITHUB_REF_TYPE" = tag ] && gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
30
+ done=true
31
+ echo "$TAG is already released: nothing to do"
32
+ fi
33
+ echo "done=$done" >> "$GITHUB_OUTPUT"
34
+
35
+ ci:
36
+ needs: released
37
+ if: needs.released.outputs.done != 'true'
38
+ uses: ./.github/workflows/ci.yml
39
+ permissions:
40
+ contents: read
41
+
42
+ github-release:
43
+ needs: ci
44
+ if: github.event_name == 'push' && github.ref_type == 'tag'
45
+ runs-on: ubuntu-latest
46
+ timeout-minutes: 10
47
+ permissions:
48
+ contents: write
49
+ steps:
50
+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
51
+ with:
52
+ persist-credentials: false
53
+ - uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
54
+ - name: Build
55
+ run: |
56
+ version="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
57
+ [ "${GITHUB_REF_NAME#v}" = "$version" ] || { echo "tag $GITHUB_REF_NAME is not version $version" >&2; exit 1; }
58
+ uv build
59
+ - env:
60
+ GH_TOKEN: ${{ github.token }}
61
+ TAG: ${{ github.ref_name }}
62
+ run: |
63
+ object=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$TAG" --jq 'select(.object.type == "tag") | .object.sha')
64
+ test -n "$object" || { echo "::error::$TAG is not an annotated tag carrying release notes"; exit 1; }
65
+ gh api "repos/$GITHUB_REPOSITORY/git/tags/$object" --jq .message > "$RUNNER_TEMP/notes.md"
66
+ gh release create "$TAG" dist/* --repo "$GITHUB_REPOSITORY" --verify-tag --title "$TAG" --notes-file "$RUNNER_TEMP/notes.md"
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ .pytest_cache/
6
+ .mypy_cache/
7
+ .ruff_cache/
8
+ dist/
9
+ build/
10
+ *.sqlite
11
+ *.sqlite-shm
12
+ *.sqlite-wal
13
+ .env
14
+ .env.*
@@ -0,0 +1,3 @@
1
+ schema = 1
2
+ repository = "benjamin-di/centralbank-data"
3
+ images = []
@@ -0,0 +1,16 @@
1
+ # centralbank-data — agent guide
2
+
3
+ Public, library-first Python SDK, CLI, local SQLite FTS5 catalog/cache, and FastMCP 4 MCP server for European and UK central bank data warehouses.
4
+
5
+ ## Key Documents
6
+ - [docs/DESIGN.md](docs/DESIGN.md) — architecture, exact-key `SeriesID`/`Observation` model, public API & error enum, SQLite WAL full-replace cache, SDMX dialect profiles, CLI/MCP contracts, prior-art record, and roadmap.
7
+ - [docs/CENTRAL_BANKS.md](docs/CENTRAL_BANKS.md) — live-verified technical reference for the 10 targeted European & UK warehouses (plus documented parked/blocked banks).
8
+ - [docs/PROVIDERS.md](docs/PROVIDERS.md) — provider capability matrix and documented limits.
9
+ - [docs/PERMISSIONS.md](docs/PERMISSIONS.md) — read-only public-data boundary and HTTP bearer contract.
10
+
11
+ ## Rules
12
+ - **Public repository**: never commit private fleet names, internal hosts, credentials, or real personal records. All test fixtures must be synthetic or scrubbed public statistical payloads.
13
+ - **Zero-bloat core**: keep core models, transport, cache, and provider adapters free of MCP or DataFrame dependencies (`httpx` + `defusedxml` only; `[mcp]` is an optional extra; `SeriesData.to_pandas()` imports `pandas` lazily).
14
+ - **Single network boundary**: all HTTP requests must pass through `src/centralbank_data/transport.py` with TOML-pinned host allowlists, per-hop redirect validation, `16 MiB` decoded outbound streaming byte cap, pacing, and a minimal in-memory circuit breaker.
15
+ - **Offline CI**: no unit or contract test may contact a live central bank API. Enforce `ENFORCE_SKIP_LEDGER=1 make check` (`ruff`, `mypy --strict`, `pytest -m "not live"`, `surface.json` ratchet). Live staleness canaries are gated with `@pytest.mark.live`.
16
+ - **Provider changes**: adding or modifying a provider requires a TOML definition in `src/centralbank_data/provider_definitions/`, offline contract fixtures/tests, and an update to `docs/PROVIDERS.md`.
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ All notable changes to `centralbank-data` will be documented in this file.
4
+
5
+ ## [0.3.1] - 2026-11-30
6
+
7
+ ### Added
8
+ - Non-root, read-only-rootfs compatible `Dockerfile` (`centralbank-data-mcp --transport http --host 0.0.0.0 --port 8080 --cache-dir /state`) and `.github/workflows/docker.yml` publishing `ghcr.io/benjamin-di/centralbank-data` on tagged releases.
9
+ - Real-wire Streamable HTTP TCP, stdio subprocess, and CLI subprocess E2E suite (`tests/test_e2e.py`).
10
+
11
+ ## [0.3.0] - 2026-11-30
12
+
13
+ ### Added
14
+ - **Swiss National Bank (`snb`)**: Cube REST/CSV adapter with `?dimSel=` single-series filtering, UTF-8 BOM + 2-line preamble stripping, `snbgwdzid` (`LZ` policy rate + `SARON`), `plkopr` (`VVP` Swiss CPI YoY), and explicit per-100 FX normalization (`DKK100`, `NOK100`).
15
+ - **Sveriges Riksbank (`riksbank`)**: Dual-API REST JSON adapter covering `/swea/v1/` (`SECBREPOEFF`, `SEGVB10YC`) and `/swestr/v1/all/SWESTR`, with optional `RIKSBANK_API_KEY` (`Ocp-Apim-Subscription-Key`).
16
+ - **Danmarks Nationalbank (`nationalbanken`)**: StatBank v1 REST adapter (`DN*` table discovery on `api.statbank.dk/v1/`, explicit `POST /v1/data` variable selection with `Tid=["(-n+500)"]` daily windowing, `YYYYMmmDdd` date normalization).
17
+ - Extended `compare_indicators` across all 10 roadmap providers (7 central banks in `policy_rate`, 5 in `overnight_rate`, 5 in `gov_yield_10y`, 3 in `cpi_yoy`).
18
+
19
+ ## [0.2.0] - 2026-11-30
20
+
21
+ ### Added
22
+ - **Bank of England (`boe`) IADB CSV provider**: `CSVF=TT` title extraction, `302 -> ErrorPage.asp` error interception, blank trailing cell handling, catalog-frequency date normalization (`LPMAUYN` monthly vs daily rates/FX), and 6 curated seed series (`IUDBEDR`, `IUDSOIA`, `IUDMNPY`, `XUDLUSS`, `XUDLERS`, `LPMAUYN`).
23
+ - **5 SDMX-native European profiles**:
24
+ - **BIS (`bis`)** — SDMX v2 JSON dataflows + `CL_BIS_UNIT` numeric unit mapping (`368` → `"Per cent per year"`), `WS_CBPOL`.
25
+ - **Deutsche Bundesbank (`bbk`)** — `/rest/metadata/dataflow/BBK`, `format=sdmx_csv`, pinned `Accept-Language: en`, `"."` missing weekend token, `BBEX3` & `BBSIS` 10Y Bund.
26
+ - **Norges Bank (`nb`)** — `;` interleaved CSV, `IR` policy rate, `SHORT_RATES` NOWA, `GOVT_GENERIC_RATES` 10Y bond, `EXR`.
27
+ - **Eurostat (`estat`)** — `lazy_catalog = true` guard (7.08 MiB catalog), `prc_hicp_minr/M.RCH_A.TOTAL.EA`.
28
+ - **National Bank of Belgium (`nbb`)** — `nsidisseminate-stat.nbb.be/rest`, agency `BE2`, `DF_EXR`.
29
+ - **Cross-bank `compare_indicators`**: Python SDK (`CentralBankService.compare_indicators`), CLI (`cbdata compare`), and 6th read-only MCP tool (`cb_compare_indicators`) with step/forward-fill alignment and per-provider partial-failure resilience.
30
+
31
+ ## [0.1.0] - 2026-11-30
32
+
33
+ ### Added
34
+ - Zero-bloat Python SDK (`>=3.11`, `httpx` + `defusedxml`), `transport.py`, SQLite WAL full-replace cache + sanitized FTS5, SDMX 2.1 engine + ECB provider (28 seed series), `cbdata` CLI, and 5-tool FastMCP 4 MCP server.
@@ -0,0 +1,12 @@
1
+ # Contributing
2
+
3
+ Contributions are welcome — especially European central bank adapters, curated macro series mappings, and regression tests for provider API quirks.
4
+
5
+ ## How changes land
6
+
7
+ This repository is the maintained public source for `centralbank-data`. Open issues and pull requests directly here.
8
+
9
+ - Keep core dependencies minimal (`httpx` and `defusedxml` only; `[mcp]` remains an optional extra).
10
+ - All network I/O must go through `src/centralbank_data/transport.py` with explicit host allowlists declared in `src/centralbank_data/provider_definitions/<provider>.toml`.
11
+ - Keep tests offline: use synthetic or recorded public statistical fixtures and gate any live-API smoke tests with `@pytest.mark.live`.
12
+ - When adding or updating a provider, update [docs/PROVIDERS.md](docs/PROVIDERS.md) and [docs/CENTRAL_BANKS.md](docs/CENTRAL_BANKS.md).
@@ -0,0 +1,32 @@
1
+ # syntax=docker/dockerfile:1.7
2
+ FROM ghcr.io/astral-sh/uv:0.9.26@sha256:9a23023be68b2ed09750ae636228e903a54a05ea56ed03a934d00fe9fbeded4b AS uv
3
+ FROM python:3.12.14-slim-trixie@sha256:f77ac9e44ae96ef2c90b8053ea08c31f8be030f824196b0ae4db6d462c84e51f
4
+
5
+ COPY --from=uv /uv /usr/local/bin/uv
6
+
7
+ WORKDIR /app
8
+ COPY pyproject.toml README.md LICENSE ./
9
+ COPY src ./src
10
+
11
+ RUN --mount=type=cache,target=/root/.cache/uv \
12
+ uv pip install --system --compile-bytecode ".[mcp]" \
13
+ && rm -rf /app/src \
14
+ && mkdir -p /state \
15
+ && chown 1000:1000 /state
16
+
17
+ ARG VERSION=0.0.0
18
+ ARG VCS_REF=unknown
19
+ ARG BUILD_DATE=unknown
20
+ LABEL org.opencontainers.image.title="centralbank-data" \
21
+ org.opencontainers.image.description="Read-only MCP server for European and UK central bank statistical warehouses" \
22
+ org.opencontainers.image.licenses="Apache-2.0" \
23
+ org.opencontainers.image.source="https://github.com/benjamin-di/centralbank-data" \
24
+ org.opencontainers.image.revision="${VCS_REF}" \
25
+ org.opencontainers.image.version="${VERSION}" \
26
+ org.opencontainers.image.created="${BUILD_DATE}"
27
+
28
+ ENV PYTHONUNBUFFERED=1
29
+ USER 1000:1000
30
+ EXPOSE 8080
31
+ ENTRYPOINT ["centralbank-data-mcp"]
32
+ CMD ["--transport", "http", "--host", "0.0.0.0", "--port", "8080", "--cache-dir", "/state"]
@@ -0,0 +1,171 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the Work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the Work's copyright
52
+ owner or by an individual or Legal Entity authorized to submit on
53
+ behalf of the copyright owner. For the purposes of this License,
54
+ "submitted" means any form of electronic, verbal, or written communication
55
+ sent to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License shall terminate as of the date
87
+ such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in Source or Object form, with or
91
+ without modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the Work; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright notices, patent notices,
102
+ trademark notices, and attribution notices from the Source
103
+ form of the Work, excluding those notices that do not pertain
104
+ to any part of the Work; and
105
+
106
+ (d) If the Work includes a "Notice" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Work, in at least one of the following
111
+ places: within a NOTICE file distributed as part of the Work;
112
+ within the Source form or documentation, if provided along with
113
+ the Work; or, within a display generated by the Derivative Works,
114
+ if and wherever such third-party notices normally appear. The
115
+ contents of the NOTICE file are for informational purposes only
116
+ and do not modify the License. You may add Your own attribution
117
+ notices within Derivative Works that You distribute, alongside
118
+ or as an addendum to the NOTICE file from the Work, provided
119
+ that such additional attribution notices cannot be construed
120
+ as modifying the License.
121
+
122
+ You may add Your own copyright notice to Your own Derivative Works
123
+ and may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your own Derivative Works,
125
+ provided that Your use, reproduction, or distribution of the Work
126
+ otherwise complies with the License.
127
+
128
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
129
+ any Contribution intentionally submitted for inclusion in the Work
130
+ by You to the Licensor shall not be subject to any additional terms
131
+ or conditions. Notwithstanding the above, nothing herein shall
132
+ supersede or modify the terms of any separate license agreement you
133
+ may have executed with Licensor regarding such Contributions.
134
+
135
+ 6. Trademarks. This License does not grant permission to use the trade
136
+ names, trademarks, service marks, or product names of the Work,
137
+ except as required for reasonable and sincere use in describing the
138
+ origin of the Work and reproducing the content of the Work's NOTICE
139
+ file.
140
+
141
+ 7. Disclaimer of Warranty. Unless required by applicable law or
142
+ agreed to in writing, Licensor provides the Work (and each
143
+ Contributor provides its own Contributions) on an "AS IS" BASIS,
144
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
145
+ implied, including, without limitation, any warranties or conditions
146
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
147
+ PARTICULAR PURPOSE. You are solely responsible for determining the
148
+ appropriateness of using or redistributing the Work and assume any
149
+ risks associated with Your exercise of permissions under this License.
150
+
151
+ 8. Limitation of Liability. In no event and under no condition shall
152
+ any Contributor be liable to You for damages, including any direct,
153
+ indirect, special, incidental, or consequential damages of any
154
+ character arising as a result of this License or out of the use or
155
+ inability to use the Work (including but not limited to damages for
156
+ loss of goodwill, work stoppage, computer failure or malfunction,
157
+ or any and all other commercial damages or losses), even if such
158
+ Contributor has been advised of the possibility of such damages.
159
+
160
+ 9. Accepting Warranty or Additional Liability. While redistributing
161
+ the Work or Derivative Works thereof, You may choose to offer,
162
+ and charge a fee for, acceptance of support, warranty, or indemnity
163
+ obligations and/or other liability obligations consistent with this
164
+ License. However, in accepting such obligations, You may act only
165
+ on Your own behalf and on Your own sole responsibility, not on behalf
166
+ of any other Contributor, and only if You agree to indemnify,
167
+ defend, and hold each Contributor harmless for any liability
168
+ incurred by, or claims asserted against, such Contributor by reason
169
+ of your accepting any such warranty or additional liability.
170
+
171
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,19 @@
1
+ .PHONY: bootstrap check check-fast lock live
2
+
3
+ bootstrap:
4
+ uv sync --extra mcp --extra dev
5
+
6
+ lock:
7
+ uv lock
8
+
9
+ check-fast:
10
+ uv run ruff check src tests
11
+ uv run ruff format --check src tests
12
+ uv run mypy src tests
13
+ git diff --check
14
+
15
+ check: check-fast
16
+ ENFORCE_SKIP_LEDGER=1 uv run pytest -m "not live" --junitxml=junit-python.xml
17
+
18
+ live:
19
+ uv run pytest -m live -v
@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.5
2
+ Name: centralbank-data
3
+ Version: 0.8.1
4
+ Summary: Unified Python SDK, CLI, local metadata catalog, and MCP server for European and UK central bank data warehouses.
5
+ Project-URL: Homepage, https://github.com/benjamin-di/centralbank-data
6
+ Project-URL: Repository, https://github.com/benjamin-di/centralbank-data
7
+ Project-URL: Documentation, https://github.com/benjamin-di/centralbank-data/blob/main/docs/DESIGN.md
8
+ Project-URL: Issues, https://github.com/benjamin-di/centralbank-data/issues
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: bank-of-england,central-bank,ecb,macroeconomics,mcp,mcp-server,sdmx,time-series
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Financial and Insurance Industry
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: defusedxml>=0.7.1
23
+ Requires-Dist: httpx>=0.28.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: hypothesis>=6.120.0; extra == 'dev'
26
+ Requires-Dist: mypy>=1.14.0; extra == 'dev'
27
+ Requires-Dist: pytest>=8.3.0; extra == 'dev'
28
+ Requires-Dist: ruff>=0.9.0; extra == 'dev'
29
+ Requires-Dist: types-defusedxml>=0.7.0; extra == 'dev'
30
+ Provides-Extra: mcp
31
+ Requires-Dist: fastmcp>=4.0.0; extra == 'mcp'
32
+ Requires-Dist: pydantic>=2.10.0; extra == 'mcp'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # centralbank-data
36
+
37
+ Unified **Python SDK**, **CLI**, **local metadata catalog & cache**, and **MCP server** for European and UK central bank data warehouses — starting with the **European Central Bank (ECB)**.
38
+
39
+ `centralbank-data` is built **library-first** with a **2-dependency pure-Python core** (`httpx` + `defusedxml`): downstream Python applications, risk/analytics pipelines, and notebooks can import the core package directly with zero MCP, pandas, pyarrow, or lxml overhead, while AI agents query the exact same normalized service through a compact, read-only MCP surface.
40
+
41
+ > **Status:** `v0.3.0` — All 10 roadmap providers (**ECB, Bank of England, BIS, Bundesbank, Norges Bank, Eurostat, NBB, SNB, Sveriges Riksbank, Danmarks Nationalbank**), `cbdata` CLI, and 6-tool FastMCP 4 MCP server are implemented and verified.
42
+
43
+ ## Quick Start
44
+
45
+ ```bash
46
+ # Core Python SDK + CLI (only httpx + defusedxml, Python >=3.11)
47
+ uv add centralbank-data
48
+
49
+ # With optional FastMCP 4 MCP server
50
+ uv add "centralbank-data[mcp]"
51
+ ```
52
+
53
+ ```python
54
+ from centralbank_data import CentralBankService
55
+
56
+ cb = CentralBankService()
57
+ hits = cb.search("EUR/USD")
58
+ exr = cb.get_series("ecb:EXR:D.USD.EUR.SP00.A", last_n=5)
59
+ ```
60
+
61
+ ```bash
62
+ cbdata search "Deposit Facility Rate"
63
+ cbdata fetch ecb:FM:D.U2.EUR.4F.KR.DFR.LEV --last-n 5 --format csv
64
+ centralbank-data-mcp --transport stdio
65
+ ```
66
+
67
+ ## Why this exists
68
+
69
+ European and UK central banks publish rich, free, authoritative macroeconomic and financial datasets — policy rates, yield curves, exchange rates, HICP inflation, money supply, bank lending surveys, credit aggregates, and balance sheets — but their data warehouses are fragmented across:
70
+
71
+ - **SDMX 2.1 / 3.0 REST APIs** (ECB, Deutsche Bundesbank, Norges Bank, National Bank of Belgium, BIS, Eurostat)
72
+ - **Custom REST / Cube & StatBank APIs** (Swiss National Bank, Sveriges Riksbank, Danmarks Nationalbank)
73
+ - **Legacy CSV endpoints** (Bank of England IADB)
74
+
75
+ Working directly against these warehouses has two recurring friction points:
76
+ 1. **Cryptic series keys & heavy metadata**: querying ECB requires knowing keys like `FM.D.U2.EUR.4F.KR.DFR.LEV` across 215 SDMX dataflows; Bank of England IADB has no search API at all; Eurostat's dataflow catalog alone is 7.08 MB (8,167 datasets).
77
+ 2. **Inconsistent wire formats & dialects**: CSV delimiters (`,` vs `;`, locale-dependent on Bundesbank), UTF-8 BOMs, missing-value tokens (`"."` on Bundesbank, blank cells on BoE), non-ISO dates (`02 Jan 2026`, `2026M11D26`), and historical revisions vary by bank.
78
+
79
+ `centralbank-data` solves both once:
80
+ - **Normalized data model**: exact-key `SeriesID` (`<provider>:<dataset>:<key>`), one `Observation` schema with full-series atomic replace caching, and canonical cross-bank indicator mappings.
81
+ - **Local SQLite FTS5 catalog & observation cache**: plain-English search (sanitized against FTS5 syntax errors) across dataflows, codelists, and curated series without dumping megabytes of SDMX XML into LLM context.
82
+ - **Multiple thin interfaces over one synchronous core**:
83
+ - **Python SDK** (`pip install centralbank-data`) — 2 pure-Python deps (`httpx`, `defusedxml`), zero MCP/pandas/pyarrow/lxml bloat.
84
+ - **CLI** (`cbdata`) — ad-hoc inspection, catalog sync, CSV/JSON output.
85
+ - **MCP server** (`pip install "centralbank-data[mcp]"`) — compact, read-only 5-tool FastMCP 4 server over stdio or Streamable HTTP.
86
+
87
+ ## Roadmap (10 High-Signal Providers)
88
+
89
+ | Phase | Central Banks / Hubs | Protocol Family |
90
+ |---|---|---|
91
+ | **Phase 1 (`v0.1.0`)** | **ECB** (215 dataflows on `data-api.ecb.europa.eu`) | SDMX 2.1 dialect engine (`defusedxml` + `csv`) |
92
+ | **Phase 2 (`v0.2.0`)** | **Bank of England (BoE IADB)** + **BIS**, **Bundesbank**, **Norges Bank**, **Eurostat**, **NBB** | BoE IADB CSV adapter + 5 SDMX profiles + `cb_compare_indicators` |
93
+ | **Phase 3 (`v0.3.0`)** | **SNB**, **Sveriges Riksbank** (SWEA + SWESTR), **Danmarks Nationalbank** | Non-Eurozone sovereign REST / Cube / StatBank adapters |
94
+
95
+ *(Narrow FX-only/SOAP adapters and redundant/WAF-blocked Eurozone NCBs are documented in [docs/CENTRAL_BANKS.md](docs/CENTRAL_BANKS.md) and intentionally parked — their headline FX and policy rates are already covered via ECB and BIS.)*
96
+
97
+ ## Documentation
98
+
99
+ - [Architecture & Design](docs/DESIGN.md) — system layers, exact-key data model, full-replace SQLite WAL cache, SDMX dialect profiles, CLI/MCP contracts, verification bar, and prior-art record.
100
+ - [Central Bank Data Warehouses](docs/CENTRAL_BANKS.md) — live-verified technical reference of the 10 target institutions plus parked/blocked European central banks.
101
+ - [Provider Capability Matrix](docs/PROVIDERS.md) — per-provider scope, status, dialect quirks, and documented limits.
102
+ - [Permissions & Multi-User Model](docs/PERMISSIONS.md) — read-only public-data boundary and HTTP bearer contract.
103
+ - [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md) · [Changelog](CHANGELOG.md)
104
+
105
+ ## License
106
+
107
+ Apache-2.0 — see [LICENSE](LICENSE).