
Swiss Efv Mcp
io.github.malkreide由 GitHub 帳號 malkreide 發布v0.4.0更新於 Oct 24, 2026
MCP server for Swiss federal finances (EFV): budget, debt, forecasts and spending data
概覽
唯讀 MCP 伺服器,提供瑞士聯邦預算、債務、收入、支出與預測資料(來自 EFV 開放資料)。
- 可以做什麼
- 以精選的 EFV FS/GFS 傾印檔案提供五個唯讀工具:fiscal_headline 回傳 1990 至 2029 年的收入、支出、結餘與債務比率,並以 is_projection 標記預測年份;fiscal_budget_breakdown 提供聯邦預算的階層式細分;fiscal_by_institution 提供 2007 年以來各部門或行政單位的支出;fiscal_list_dimensions 用來探索有效參數值;fiscal_status 回報快取新鮮度與上游健康狀態。資料從公開的 EFV 端點取得,並在記憶體中快取 24 小時。
- 適用情境
- 適合需要瑞士聯邦財政數據、預算階層細分或各部門支出的情境,也可與貨幣政策伺服器搭配,將利率週期與聯邦赤字連結起來。不適用於官方或權威用途。
- 執行需求
- 本機程序,以 uvx 或 pip 執行;建議 Python 3.11+ 及 uv/uvx。需要連線至 data.finance.admin.ch 與 efv.admin.ch。不需要 API 金鑰或身分驗證。可選環境變數用於設定傳輸方式、主機、連接埠、日誌層級、CORS 來源與 OpenTelemetry。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Swiss Efv Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
🇨🇭 Part of the Swiss Public Data MCP Portfolio — open-source MCP servers connecting AI agents to Swiss public and open data. This is a private project. It is independent of any employer or institutional affiliation.
🏛️ swiss-efv-mcp
[Version] [CI] [License: MIT] [Python 3.11+] [MCP] [Auth: none] [Portfolio]
MCP server for Swiss federal finances (EFV): budget, debt, forecasts and spending by task and institution.
Overview
This server closes the fiscal gap in the portfolio's Economics & Finance cluster.
swiss-snb-mcp already covers monetary policy; swiss-efv-mcp adds the state
budget — federal revenue, expenditure, balance, debt ratios (with forecasts to
2029), a hierarchical budget drill-down, and spending by department. Data comes
from the Eidgenössische Finanzverwaltung (EFV) via opendata.swiss (OGD Schweiz).
Features
- Five read-only tools over the curated EFV FS/GFS dump files.
- Headline series 1990–2029 per household (bund, ktn, gdn, staat, sv) and model
(FS / GFS); every point carries
is_projectionso actuals and plan/forecast years are unambiguous. - Hierarchical federal-budget drill-down and spending by department / unit.
- 24 h TTL in-memory cache with stale-serve fallback; retry with exponential
backoff (2/4/8 s);
dump_statusnever returns empty silently. - Dual transport:
stdio(local) and SSE (cloud). - No authentication required — public open-government data (No-Auth-First).
🎯 Anchor Demo Query
"How has the federal balance developed since the SNB rate turnaround in 2022 — and which task areas absorbed the growth in spending?"
Cross-read with swiss-snb-mcp, this connects the interest-rate cycle to the
federal deficit — something neither server can answer alone.
Demo
[Demo: Claude using fiscal_headline and fiscal_budget_breakdown]
Prerequisites
- Python 3.11+
uv/uvx(recommended) orpip- Network access to
data.finance.admin.chandefv.admin.ch— no API key needed
Installation
Claude Desktop (claude_desktop_config.json):
Quickstart
Configuration
All configuration is loaded once into a typed Settings object
(pydantic-settings). The legacy unprefixed names below keep working; the
canonical names use the EFV_MCP_ prefix. Defaults are safe for local use.
Cloud (Render / Railway):
Available Tools
All tools are read-only: each is annotated readOnlyHint: true,
destructiveHint: false, only issues HTTP GETs against the EFV dump files, and
has no write, send, or filesystem capability.
MCP primitives. This server uses only the Tools primitive. The EFV data
are sliced live from cached dumps with no stable resource hierarchy to expose as
Resources, and there are no server-authored Prompts. The five tools are small
and closely related, so they live in a single server.py rather than a tools/
package.
Architecture
Architecture decision
This server uses Architecture C (Dump-first).
Rationale (verified live on 2026-07-24):
- The EFV FS/GFS dashboard has no filtered query API; it serves static CSV dumps that its front-end filters in the browser.
- Three curated files are small enough to fetch-and-cache whole (516 KB / 5 MB / 1 MB). They cover the headline aggregates, the hierarchical budget and the by-institution view — i.e. the answerable questions.
- The full detail cubes (
standardauswertung.csv157 MB,fir_art_funk.csv1.23 GB) are out of scope for v0.1.0; loading them per request is not viable. A future Phase 2 would pre-process them into SQLite/Parquet.
Consequences:
- Files are cached in memory with a 24 h TTL; stale cache is preferred over an empty response when upstream is down.
- Retry with exponential backoff on all HTTP;
dump_statusalways returns a readable state.
Project Structure
Safety & Limits
- Read-only. Every tool is annotated
readOnlyHint: true, only issues HTTP GETs against the EFV dump files, and has no write, send, or filesystem capability. - Egress allow-list. An immutable
ALLOWED_HOSTSfrozenset +assert_host_allowed()is enforced before every request (HTTPS-only, two fixed EFV hosts). URLs are hardcoded constants; no user input builds a URL. Seedocs/network-egress.md. - TLS on. httpx certificate verification is on by default and never disabled.
- No credentials. The endpoints are public OGD; no API keys or secrets are
stored or forwarded. A browser
User-Agentis injected because the endpoints403the default httpx/curl UA (see Known limitations) — do not remove it. - Error masking.
mask_error_details=Trueplus client-side masking keep raw upstream/internal detail out of tool results; full detail goes only to the structlog stderr log. - Input bounds. Tool arguments carry explicit Pydantic constraints (year
1900–2100,level 1–8, stringmax_length). - Graceful degradation. Retry with exponential backoff (2/4/8 s); a stale
cache is served over an empty response;
dump_statusalways returns a readable state and never a silent empty. - Loopback + default-deny CORS. SSE binds to
HOST, default127.0.0.1; setHOST=0.0.0.0only inside a container (the providedDockerfiledoes). Browser origins must be listed explicitly viaEFV_MCP_CORS_ORIGINS. - Audited. Reviewed against the portfolio MCP best-practice catalogue
(44 applicable checks) — see
audits/andSECURITY.md. Accepted risks are documented as ADRs underdocs/adr/. - Not authoritative. Figures are not official; consult the EFV originals for official use.
Known limitations
Live-probe findings (2026-07-24), also in CHANGELOG.md → Known findings:
Project Phase
This server is in Phase 1 (read-only). Every tool only ever fetches the public EFV dump files — there are no write, send, or filesystem capabilities.
A transition to a later phase would require a re-audit before any write-capable tool is added.
MCP Protocol Version
This server is native to MCP spec 2026-07-28 and still serves the older
handshake era, so both pins are stated — a single number would describe only
half of what clients actually get.
Both constants live in server.py and are held against the mcp SDK's own
LATEST_MODERN_VERSION / LATEST_HANDSHAKE_VERSION rather than against
copied-out spec text, and both eras are exercised over a real connection — a
protocol-changing SDK bump fails CI loudly instead of drifting silently
(ARCH-012).
The 2026-07-28 era carries consequences beyond the number:
- Routing headers. Every modern request carries
Mcp-Protocol-Version,Mcp-Methodand (fortools/call)Mcp-Name. They are listed in the CORS allow-list in__main__.py; without them a browser client fails at the preflight and never reaches the server.Mcp-Param-*is deliberately absent — no tool schema here carries thex-mcp-headerannotation that would make a client send one, and a test fails the day one does. - Logging is deprecated (SEP-2577). Tool handlers no longer send
client-facing log notifications; per-call diagnostics go to the structlog
stderr stream, honouring
EFV_MCP_LOG_LEVEL. Progress reporting is unaffected and stays. fastmcp>=4.0is a floor, not cosmetics. Only fastmcp 4 pulls inmcp2.x, and only there does revision2026-07-28exist at all. Under fastmcp 3.x this server would speak2025-11-25at best.
Dependencies are kept current via monthly Dependabot PRs
(.github/dependabot.yml); protocol-relevant bumps are noted in
CHANGELOG.md.
Testing
Changelog
See CHANGELOG.md.
Contributing
Issues and pull requests are welcome. Please keep tools read-only, run
ruff check and the offline test suite before submitting, and add a
CHANGELOG.md entry under [Unreleased] for user-facing changes. See
CONTRIBUTING.md.
Maintainers: see PUBLISHING.md for the step-by-step PyPI release process (Trusted Publishing via GitHub Release).
Security
See SECURITY.md for the security posture, hardening controls, and how to report a vulnerability.
License
MIT for this server — see LICENSE. The EFV data remain subject to the OGD Schweiz terms (freely usable, with attribution).
Author
Hayal Oezkan · github.com/malkreide
Credits & Related Projects
- Data: Eidgenössische Finanzverwaltung EFV via opendata.swiss (OGD Schweiz, freely usable)
- Companion:
swiss-snb-mcp(monetary policy) — the fiscal/monetary pair - Portfolio index: swiss-public-data-mcp
Disclaimer: private project, independent of any employer or institution. No warranty; figures are not authoritative — consult the EFV originals for official use.
來源:README.md,提交 abbcbf0
工具
0版本歷史
2- v0.4.0最新Sep 26, 2026
- v0.3.2Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分