Skip to main content

MCP server for Swiss National Bank (SNB) data portal โ€” exchange rates, balance sheet, and monetary statistics

Project description

๐Ÿ‡จ๐Ÿ‡ญ Part of the Swiss Public Data MCP Portfolio

๐Ÿฆ swiss-snb-mcp

Version License: MIT Python 3.11+ MCP Data Source

MCP server for the Swiss National Bank (SNB) data portal โ€” exchange rates, balance sheet, interest rates, SARON, and monetary aggregates.

๐Ÿ‡ฉ๐Ÿ‡ช Deutsche Version


Overview

swiss-snb-mcp connects AI models to the official Swiss National Bank data portal at data.snb.ch via the Model Context Protocol (MCP). It provides structured access to SNB's public REST API โ€” no authentication required.

The server covers two tiers of datasets, all confirmed against the live API:

Phase 1 โ€” Dedicated tools:

  • Exchange rates (monthly averages, month-end rates, annual averages) for 27 currencies against CHF
  • SNB balance sheet (Bilanz): gold reserves, foreign exchange investments, banknotes in circulation, sight deposits, and totals

Phase 2 โ€” Via generic cube tools (snb_get_cube_data + snb_get_cube_metadata):

  • SNB policy rate (Leitzins) and SARON daily fixing, emergency facility rate, sight deposit rates
  • SARON compound rates: Overnight, 1M, 3M, 6M
  • International money market rates: SARON (CH), SOFR (USA), TONA (JP), SONIA (UK), โ‚ฌSTR/EURIBOR (EZ)
  • Official central bank rates: SNB, Fed, ECB, Bank of England, Bank of Japan
  • Monetary aggregates M1, M2, M3: stock levels and year-on-year changes

Anchor demo query: "What was the EUR/CHF exchange rate during the 2015 Franc shock, and where does the SNB policy rate stand today compared to the Fed and ECB?"


Features

  • ๐Ÿ’ฑ Exchange rates โ€” monthly CHF rates for EUR, USD, JPY, GBP, CNY and 22 more currencies
  • ๐Ÿ“… Annual averages โ€” year-by-year rates from 1980 onwards
  • ๐Ÿ›๏ธ SNB balance sheet โ€” gold, foreign exchange investments, banknotes, sight deposits (monthly)
  • ๐Ÿ”„ Currency conversion โ€” convert any amount to CHF using official SNB rates
  • ๐Ÿ“ˆ Policy rate & SARON โ€” daily fixing, Leitzins, compound rates (1M/3M/6M)
  • ๐ŸŒ International rate comparison โ€” SNB, Fed, ECB, Bank of England, Bank of Japan side by side
  • ๐Ÿ’ฐ Monetary aggregates โ€” M1, M2, M3 stock levels and year-on-year growth
  • ๐Ÿ” Generic cube access โ€” query any SNB data cube by ID for advanced use cases
  • ๐Ÿ”“ No authentication required โ€” fully public SNB data portal

Prerequisites

  • Python 3.11+
  • uv or pip
  • MCP-compatible client (Claude Desktop, Claude Code, or any MCP host)

Installation

Via uvx (recommended โ€” no permanent installation needed):

uvx swiss-snb-mcp

Via pip:

pip install swiss-snb-mcp

From source:

git clone https://github.com/malkreide/swiss-snb-mcp.git
cd swiss-snb-mcp
pip install -e .

Usage / Quickstart

Claude Desktop โ€” add to claude_desktop_config.json:

{
  "mcpServers": {
    "swiss-snb-mcp": {
      "command": "uvx",
      "args": ["swiss-snb-mcp"]
    }
  }
}

Config file locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Try it immediately in Claude Desktop:

"What is the current EUR/CHF exchange rate according to the SNB?" "Show me the SNB balance sheet for the last 12 months โ€” gold and foreign reserves."


Configuration

No API key or authentication required. The SNB data portal is fully public.

Optional environment variable:

Variable Default Description
SNB_TIMEOUT 15 HTTP request timeout in seconds

Available Tools

Phase 1 โ€” Dedicated Tools

Tool Description
snb_get_exchange_rates Monthly CHF rates for EUR, USD, JPY, GBP, CNY and 22 more currencies
snb_get_annual_exchange_rates Annual average rates, data from 1980
snb_get_balance_sheet SNB Bilanz positions in millions CHF (monthly)
snb_convert_currency Convert any amount to CHF using official SNB rates
snb_list_currencies List all 27 currency IDs with labels and units
snb_list_balance_sheet_positions List all asset and liability position IDs

Phase 2 โ€” Generic Cube Tools

Tool Description
snb_get_cube_data Generic access to any SNB cube by ID
snb_get_cube_metadata Inspect dimensions and filter values of any cube
snb_list_known_cubes Overview of all 8 verified cubes (Phase 1 + 2) and discovery guide

Example Use Cases

Query Tool
"What is the current EUR/CHF rate?" snb_get_exchange_rates
"Convert CHF 10,000 to USD" snb_convert_currency
"Show SNB gold reserves over the last year" snb_get_balance_sheet
"What is the current SNB policy rate?" snb_get_cube_data (cube: snb_leitzinsen)
"How do SNB, Fed and ECB rates compare?" snb_get_cube_data (cube: zib_gab)
"What is the SARON 3M compound rate?" snb_get_cube_data (cube: snb_saron_compound)
"How fast is M3 money supply growing?" snb_get_cube_data (cube: snb_geldmengen)
"Which cubes are available?" snb_list_known_cubes

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Claude / AI   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚     Swiss SNB MCP         โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚     data.snb.ch      โ”‚
โ”‚   (MCP Host)    โ”‚โ—€โ”€โ”€โ”€โ”€โ”‚     (MCP Server)          โ”‚โ—€โ”€โ”€โ”€โ”€โ”‚                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚                           โ”‚     โ”‚  REST API (JSON)     โ”‚
                        โ”‚  9 Tools                  โ”‚     โ”‚  Public ยท No Auth    โ”‚
                        โ”‚  Stdio | SSE              โ”‚     โ”‚                      โ”‚
                        โ”‚                           โ”‚     โ”‚  Exchange rates      โ”‚
                        โ”‚  Phase 1: dedicated tools โ”‚     โ”‚  Balance sheet       โ”‚
                        โ”‚  Phase 2: generic cubes   โ”‚     โ”‚  Interest rates      โ”‚
                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚  SARON               โ”‚
                                                          โ”‚  Monetary aggregates โ”‚
                                                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Cube Discovery Pattern

The SNB API follows a consistent cube-based structure. Use snb_list_known_cubes to explore verified cube IDs, then snb_get_cube_metadata to inspect dimensions before querying with snb_get_cube_data. This generic layer gives access to the full SNB data catalogue without needing dedicated tools for each dataset.


Project Structure

swiss-snb-mcp/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ swiss_snb_mcp/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ server.py       # All tools and FastMCP server
โ”œโ”€โ”€ tests/                  # Test suite
โ”œโ”€โ”€ pyproject.toml          # Build configuration (hatchling)
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md               # This file (English)
โ””โ”€โ”€ README.de.md            # German version

Known Limitations

  • Exchange rates: Monthly averages only โ€” no intraday or daily rates available via this API
  • Balance sheet: Monthly data; some positions may have a publication lag of 1โ€“2 months
  • Cube access: Cube IDs are not officially documented by the SNB โ€” use snb_list_known_cubes for verified IDs
  • Historical depth: Coverage varies by series; exchange rates go back to 1980, some interest rate series start later
  • No forecasts: All data is historical/realised โ€” SNB does not publish forecasts via this API

Testing

# Unit tests (no API key required)
PYTHONPATH=src pytest tests/ -m "not live"

# Integration tests (live SNB API)
PYTHONPATH=src pytest tests/ -m "live"

Changelog

See CHANGELOG.md


Contributing

See CONTRIBUTING.md for guidelines on reporting issues, suggesting new SNB cube IDs, and contributing code.


License

MIT License โ€” see LICENSE


Author

Hayal Oezkan ยท github.com/malkreide


Credits & Related Projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swiss_snb_mcp-0.2.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swiss_snb_mcp-0.2.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file swiss_snb_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: swiss_snb_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for swiss_snb_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f9b0642f301b3d31772b61451d9b9481d16d5ead22957be8ce9d107803436479
MD5 b0d24d63f45ec76590f9d3cf26ba7e87
BLAKE2b-256 9ec5e7f044a9b65bc6412331b32d15647f08a4d7eb9135fefb7cf426458d02d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for swiss_snb_mcp-0.2.0.tar.gz:

Publisher: publish.yml on malkreide/swiss-snb-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swiss_snb_mcp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: swiss_snb_mcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for swiss_snb_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 108b0a8602e0267a1e013318995dc61800bb0f8caf2260e2b6e0ee93b57ec914
MD5 9e813bde343d54aa6f4bc18a91255cef
BLAKE2b-256 245b39bcbb42aeaa69d3025960500cc5d48e844b495ffa582467141c7784e844

See more details on using hashes here.

Provenance

The following attestation bundles were made for swiss_snb_mcp-0.2.0-py3-none-any.whl:

Publisher: publish.yml on malkreide/swiss-snb-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page