Swiss Snb Mcp

io.github.malkreide由 GitHub 帳號 malkreide 發布v0.5.0更新於 Oct 24, 2026

SNB data portal: exchange rates, balance sheet, policy rates, SARON, monetary aggregates

已驗證STDIO僅桌面金融資料與分析

概覽

AI 產生的概覽

唯讀 MCP 伺服器,讓助理以結構化方式存取瑞士國家銀行公開資料:匯率、資產負債表、政策利率、SARON、貨幣總量與銀行統計。

可以做什麼
  • 取得 28 個貨幣序列的月平均與年平均瑞郎匯率,並依官方匯率換算金額
  • 讀取瑞士央行資產負債表項目,例如黃金儲備、外匯投資、流通鈔券與即期存款
  • 依 ID 查詢任一 SNB 資料立方體,取得政策利率、SARON 定盤與複合利率、各國央行利率以及 M1/M2/M3 貨幣總量
  • 取得依銀行集團劃分的銀行資產負債表與損益表,以及國際收支與國際投資部位
  • 檢視立方體與倉儲中介資料,並瀏覽貨幣、立方體、銀行集團與資產負債表項目的靜態目錄
適用情境
適合需要助理依據官方資料回答瑞士貨幣政策、瑞郎匯率、央行儲備、貨幣供給或瑞士銀行業統計問題的情境,不必離開對話即可取得資料。
執行需求
以 Python 套件形式透過 stdio 在本機執行(需 Python 3.11+、uv 或 pip,例如 uvx swiss-snb-mcp)。不需 API 金鑰或帳號,但需連網存取公開的 data.snb.ch 介面。可選環境變數 SNB_TIMEOUT 設定 HTTP 逾時(預設 15 秒)。
安裝前請注意
唯讀且不需任何憑證,僅向 data.snb.ch 送出請求。資料受瑞士央行使用條款與著作權規範,非商業用途可免費使用但須標註來源。短時間大量查詢可能觸發倉儲介面的 WAF 防護,伺服器會自動退避重試。匯率僅提供月平均值,部分序列有發布延遲。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Swiss Snb Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

🇨🇭 Part of the Swiss Public Data MCP Portfolio

🏦 swiss-snb-mcp

[Version] [License: MIT] [Python 3.11+] [MCP] [Data Source] [CI]

MCP server for the Swiss National Bank (SNB) data portal — exchange rates, balance sheet, interest rates, SARON, monetary aggregates, banking statistics, and balance of payments.

🇩🇪 Deutsche Version

[Demo: Claude queries SNB banking statistics via MCP tool call]


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 three tiers of datasets, all confirmed against the live API:

Phase 1 — Dedicated tools:

  • Exchange rates (monthly averages, month-end rates, annual averages) for the 28 currency series devkum publishes against CHF — including two USD forward rates, which are labelled as such
  • 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

Phase 3 — Warehouse API (banking statistics) and balance of payments:

  • Banking balance sheets (BSTA BIL): total assets and liabilities by bank group — annual and monthly
  • Banking income statements (BSTA EFR): operating income, expenses, taxes by bank group — annual
  • Balance of payments: current account, capital account, financial account (quarterly)
  • International investment position: components by investment type (quarterly)
  • Generic warehouse access: raw access to any SNB Warehouse cube by ID

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 23 more series
  • 📅 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
  • 🏦 Banking statistics — balance sheets and income statements by bank group (12 groups)
  • 📊 Balance of payments — current account, IIP, and international investment position
  • 🔍 Generic cube access — query any SNB data cube or Warehouse cube by ID
  • 🔓 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):

bash
uvx swiss-snb-mcp

Via pip:

bash
pip install swiss-snb-mcp

From source:

bash
git clone https://github.com/malkreide/swiss-snb-mcp.gitcd swiss-snb-mcppip install -e .

Usage / Quickstart

Claude Desktop — add to claude_desktop_config.json:

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:

VariableDefaultDescription
SNB_TIMEOUT15HTTP request timeout in seconds

Available Tools

Phase 1 — Dedicated Tools

ToolDescription
snb_get_exchange_ratesMonthly CHF rates for EUR, USD, JPY, GBP, CNY and 22 more currencies
snb_get_annual_exchange_ratesAnnual average rates, data from 1980
snb_get_balance_sheetSNB Bilanz positions in millions CHF (monthly)
snb_convert_currencyConvert any amount to CHF using official SNB rates

Phase 2 — Generic Cube Tools

ToolDescription
snb_get_cube_dataGeneric access to any SNB cube by ID
snb_get_cube_metadataInspect dimensions and filter values of any cube

Phase 3 — Warehouse API (Banking Statistics) and Balance of Payments

ToolDescription
snb_get_banking_balance_sheetBanking balance sheets by bank group (monthly/annual, assets/liabilities)
snb_get_banking_incomeBanking income statements by bank group (annual)
snb_get_balance_of_paymentsBalance of payments and international investment position (quarterly)
snb_get_warehouse_dataGeneric access to any SNB Warehouse cube by ID
snb_get_warehouse_metadataInspect dimensions and last update of a Warehouse cube

Resources (static catalogs)

Discovery aids served as MCP resources rather than tools so they don't crowd the tool manifest:

URIDescription
data://snb/currenciesAll 28 currency IDs with labels and units
data://snb/balance-sheet-positionsAsset and liability position IDs
data://snb/cubesAll verified Cube-API IDs (Phase 1–2) + discovery guide
data://snb/warehouse-cubesAvailable Warehouse cube IDs (BSTA)
data://snb/bank-groupsAll 12 bank group IDs with labels

Example Use Cases

QueryTool
"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: snbgwdzid)
"How do SNB, Fed and ECB rates compare?"snb_get_cube_data (cube: snboffzisa)
"What is the SARON 3M compound rate?"snb_get_cube_data (cube: zirepo)
"How fast is M3 money supply growing?"snb_get_cube_data (cube: snbmonagg)
"Total assets of all Swiss banks?"snb_get_banking_balance_sheet
"Income statement of cantonal banks?"snb_get_banking_income (bank_group: G10)
"Switzerland's balance of payments?"snb_get_balance_of_payments
"Which cubes are available?"resource data://snb/cubes

→ More use cases by audience →


Safety & Limits

AspectDetails
AccessRead-only (readOnlyHint: true) — the server cannot modify or delete any data
Personal dataNo personal data — all sources are aggregated, public macroeconomic statistics
Rate limitsSNB Warehouse API has WAF protection (HTTP 503 after ~100 rapid requests); the server retries automatically with exponential backoff (max 3 retries, delays 2/4/8s)
Timeout15 seconds per API call
AuthenticationNo API keys required — both APIs (/api/cube/ and /api/warehouse/cube/) are publicly accessible
Data sourceSwiss National Bank — data.snb.ch
Terms of ServiceSubject to SNB's Terms of Use and Copyright; data is free for non-commercial use with source attribution

Architecture

┌─────────────────┐     ┌───────────────────────────┐     ┌──────────────────────┐│   Claude / AI   │────▶│     Swiss SNB MCP         │────▶│     data.snb.ch      ││   (MCP Host)    │◀────│     (MCP Server)          │◀────│                      │└─────────────────┘     │                           │     │  /api/cube/ (JSON)   │                        │  11 Tools · 5 Resources   │     │  /api/warehouse/     │                        │  Stdio | SSE              │     │  Public · No Auth    │                        │                           │     │                      │                        │  Phase 1: dedicated tools │     │  Exchange rates      │                        │  Phase 2: generic cubes   │     │  Balance sheet       │                        │  Phase 3: warehouse +     │     │  Interest rates      │                        │           banking stats   │     │  Banking statistics  │                        └───────────────────────────┘     │  Balance of payments │                                                          └──────────────────────┘

Cube Discovery Pattern

The SNB API follows a consistent cube-based structure. Read the data://snb/cubes resource to explore verified cube IDs, then snb_get_cube_metadata to inspect dimensions before querying with snb_get_cube_data. Phase 3 adds the Warehouse API (/api/warehouse/cube/) for granular banking statistics — start from the data://snb/warehouse-cubes and data://snb/bank-groups resources.


Project Structure

swiss-snb-mcp/├── src/│   └── swiss_snb_mcp/│       ├── __init__.py│       ├── server.py       # Core tools and FastMCP server (Phase 1–2 + BoP)│       └── warehouse.py    # Warehouse API tools (Phase 3: banking statistics)├── scripts/│   └── record_fixtures.py          # records tests/fixtures/* from data.snb.ch├── tests/│   ├── fixtures/                   # recorded responses + PROVENANCE.md (date, rule, SHA-256)│   ├── fixture_data.py             # loader — a missing name is an error, not an empty dict│   ├── test_unit.py                # respx-mocked unit tests (run in CI)│   ├── test_live_scenarios.py      # 20 live scenarios for Phase 1–2 (nightly)│   └── test_live_warehouse.py      # 20 live scenarios for Phase 3 (nightly)├── pyproject.toml          # Build configuration (hatchling)├── CHANGELOG.md├── CONTRIBUTING.md         # Contribution guidelines (English)├── CONTRIBUTING.de.md      # German version├── SECURITY.md             # Security policy & posture (English)├── SECURITY.de.md          # German version├── 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 — read the data://snb/cubes resource 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

MCP Protocol Version

This server speaks two protocol eras over the same endpoint. The client's first request on a connection decides which one applies; a later claim from the other era is refused.

EraRevisionWho reaches it
initialize handshake2024-11-05 … 2025-11-25What today's clients speak. The server answers with the revision asked for, or with the 2025-11-25 ceiling when the request asks for something newer.
Per-request envelope2026-07-28A request carrying the 2026-07-28 _meta envelope opens a modern connection.

Both revisions are pinned in tests/test_protocol_version.py and asserted against the installed SDK, so a Dependabot bump of mcp cannot move either one silently.

The table above is measured, not inferred. The same gate drives the server's real serving loop over an in-memory stream pair — the loop stdio runs in production — and sends actual JSON-RPC frames through it: an enveloped request is served at 2026-07-28, an initialize asking for 2026-07-28 is answered 2025-11-25, and a claim from the other era is refused on an already-decided connection (-32022 one way, -32600 the other). An earlier revision of this section claimed the measurement needed an ASGI app; it does not — the modern era has no initialize, and the handshake never rode on HTTP to begin with.

What the server reports about itself is measured the same way, in tests/test_server_identity.py: the package version and the project URL are read back off the wire, not off the constructor.

Note that the SDK's LATEST_PROTOCOL_VERSION is an alias for the modern era, not for the handshake era — pinning against it alone would leave the era that current clients actually negotiate free to drift.

Update policy. When the gate fails, do not edit the constant blindly: read the spec changelog between the two revisions, verify the server still behaves, then move the constant, this section, README.de.md and CHANGELOG.md together.


Testing

bash
# Unit tests (no API key required)PYTHONPATH=src pytest tests/ -m "not live"
# Integration tests (live SNB API)PYTHONPATH=src pytest tests/ -m "live"
# Re-record the fixtures from data.snb.ch (writes tests/fixtures/PROVENANCE.md)python scripts/record_fixtures.py

The unit-test payloads are recorded, not invented. Source, retrieval date, selection rule and SHA-256 per file are in tests/fixtures/PROVENANCE.md. A hand-written mock encodes its author's assumption and can therefore never refute it — production code and fixture come from the same head, so where both are wrong, both are wrong together and the suite stays green. Each file keeps every series and only shortens the value lists: the code reasons about the dimensions and merely displays the values, so cutting "the first N series" would have hidden exactly what three of the findings depended on.


Changelog

See CHANGELOG.md


Contributing

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


Security

This server is read-only, processes no personal data, and talks only to data.snb.ch. See SECURITY.md for the full security posture, audit results, and how to report a vulnerability.


License

MIT License — see LICENSE


Author

Hayal Oezkan · github.com/malkreide


Credits & Related Projects

Installation

Run via uv's uvx — no clone or manual install needed. Add to your MCP client config (mcpServers for Claude Desktop, Cursor and Windsurf; use a top-level servers key for VS Code in .vscode/mcp.json):

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

來源:README.md,提交 9b88f6f

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

2
  1. v0.5.0最新Sep 26, 2026
  2. v0.4.5Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分