
Srgssr Mcp
io.github.malkreide由 GitHub 账号 malkreide 发布v2.1.0更新于 Oct 24, 2026
SRG SSR weather, video, audio, EPG, Polis
概览
让助手以只读方式访问 SRG SSR 公开数据:瑞士天气、电视与广播元数据、节目表,以及历史公投和选举结果。
- 可以做什么
- 把 SRG SSR Public API V2 封装为约 15 个只读工具,分为五个主题:SRF Meteo 天气(地点搜索、当前天气、24 小时与 7 天预报)、视频(电视节目、剧集、直播频道)、音频(广播节目、音频剧集、直播电台)、EPG(每日电视或广播节目表)以及 Polis(1900 年以来的全国与州级公投和选举)。它还以可缓存资源形式提供 EPG 和公投数据,并提供两个提示词用于投票分析和每日简报。覆盖 SRF、RTS、RSI、RTR 和 SWI。
- 适用场景
- 适合让助手回答瑞士天气、今晚 SRF、RTS 或 RSI 播什么,以及历史瑞士投票和选举等问题,数据直接来自广播机构的 API 而非模型生成。面向瑞士公共数据以及新闻或研究工作流。
- 运行要求
- 需要 Python 3.11+,通过 uvx 或 pip 在本地运行;桌面客户端使用 stdio 传输,浏览器部署可选 SSE 或 streamable HTTP。需要 developer.srgssr.ch 的免费 OAuth2 凭据,以环境变量 SRGSSR_CONSUMER_KEY 和 SRGSSR_CONSUMER_SECRET 提供。需要访问 api.srgssr.ch 的网络连接。
安装
在 SourceWeft 中
- 打开 控制台中的 Srgssr Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
🇨🇭 Part of the Swiss Public Data MCP Portfolio
📺 srgssr-mcp
[Version] [License: MIT] [Python 3.11+] [MCP] [CI] [Data Source]
MCP server connecting AI models to SRG SSR public APIs – weather, TV/radio metadata, program guide and Swiss votations/elections since 1900 (SRF, RTS, RSI, RTR, SWI).
[Demo: Claude asks a question → srgssr-mcp tool call → grounded answer from SRG SSR Polis API]
Overview
srgssr-mcp gives AI assistants like Claude direct access to the public APIs of SRG SSR – Switzerland's national public broadcaster. Weather forecasts, TV and radio metadata, electronic program guides, and historical democratic data (votations and elections since 1900) are all accessible through a single standardised MCP interface.
The server covers five thematic clusters: SRF Weather, Video, Audio, EPG and Polis (Swiss Democracy). Each cluster maps to a group of purpose-built tools that translate raw SRG SSR API data into clean JSON responses.
Anchor demo query: "What were the cantonal results of the popular vote on initiative X in Zurich?" – answered with historical real-time data from the Polis system, not a hallucination.
Features
- 🌦️ Weather – location search, current conditions, 24h hourly forecast, 7-day forecast (SRF Meteo)
- 📺 Video – TV show listings, latest episodes, live TV channels across all business units
- 🎙️ Audio – radio show listings, audio episodes, live radio stations
- 📅 EPG – daily program schedule for any TV or radio channel
- 🗳️ Polis – popular votes and elections since 1900, national and cantonal results
- 🏢 Multi-unit – SRF (DE), RTS (FR), RSI (IT), RTR (RM), SWI (multilingual)
- 🔐 OAuth2 – automatic token management with Client Credentials flow
- ☁️ Dual transport – stdio for Claude Desktop, Streamable HTTP/SSE for cloud deployment
Prerequisites
- Python 3.11+
- API keys from developer.srgssr.ch (free registration):
- Create an account and log in
- Under "My Apps", create a new application
- Add the product SRG SSR PUBLIC API V2
- Note your Consumer Key and Consumer Secret
⚠️ Terms of use: SRG SSR APIs are available for non-commercial use. For commercial use, contact [email protected] directly.
Installation
Or with uvx (no permanent installation):
Or via pip:
Quickstart
Try it immediately in Claude Desktop:
"What will the weather be like in Zurich tomorrow?" "What's on SRF 1 tonight?" "Which popular votes took place in the canton of Bern between 2010 and 2020?"
Configuration
Claude Desktop
Minimal (recommended):
Config file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
After saving, restart Claude Desktop completely.
Other MCP Clients
Compatible with Cursor, Windsurf, VS Code + Continue, LibreChat, Cline, and self-hosted models via mcp-proxy. Set the same environment variables.
Cloud Deployment (SSE for browser access)
For use via claude.ai in the browser (e.g. on managed workstations without local software):
Transport, host, port and mount path are all driven by environment variables
(see srgssr_mcp.server.Settings). Valid values for SRGSSR_MCP_TRANSPORT
are stdio (default), sse, and streamable-http.
💡 "stdio for the developer laptop, SSE for the browser."
MCP Primitives
This server exposes all three orthogonal MCP primitives:
Tools cover parametrized searches (year ranges, free-text, paginated listings) where every call may yield different results. Resources expose stable data points that are safe to cache: a published EPG for a given channel/date, or the final result of a closed Swiss votation. Prompts standardise recurring multi-step analyses so users don't have to phrase them from scratch.
Resources
EPG station ids — hyphenated, and not the same as the livestream ids:
Prompts
Available Tools
Tool Naming Convention
This server uses snake_case for tool names, following Python ecosystem idioms. While MCP best practice favors camelCase for optimal LLM tokenization, snake_case remains acceptable and keeps tool names aligned with the underlying Python function identifiers.
All tools follow the pattern srgssr_<domain>_<action> with the namespace prefix srgssr_ and a semantically meaningful <domain>_<action> suffix (e.g. srgssr_weather_current, srgssr_polis_get_votations).
🌦️ SRF Weather (4 tools)
📺 Video (3 tools)
🎙️ Audio (3 tools)
📅 EPG – Electronic Program Guide (1 tool)
🗳️ Polis – Swiss Democracy (3 tools)
Supported Business Units
Example Use Cases
→ More use cases by audience →
Architecture
Data Sources
Attribution: SRG SSR APIs are subject to the SRG SSR Terms of Use.
Development Phase
This server is in Phase 1: Read-only Wrapper.
The server exposes only GET-style operations against public SRG SSR APIs. There are no write, mutate or delete capabilities by design — see Safety & Limits for the threat-model implications.
Phase 1 Completion Criteria
- 14 read-only tools across five thematic clusters (Weather, Video, Audio, EPG, Polis)
- OAuth2 Client Credentials authentication with token caching
- Bilingual documentation (EN/DE)
- Test suite (unit + live) — see OPS-001
- Structured logging — see OBS-003 and CHANGELOG
- Production-ready error handling (uniform retry/backoff, typed error envelopes)
Future Phases
- Phase 2 (Write): Not planned. The SRG SSR Public APIs are read-only by contract; there is no upstream surface to write to.
- Phase 3 (Multi-Agent): Evaluation deferred. Will be reconsidered once user feedback indicates concrete multi-agent workflows that this server should orchestrate (e.g. cross-server aggregation with
swiss-statistics-mcporswiss-transport-mcp).
MCP Protocol Version
mcp 2.x serves two protocol eras over the same server, and the client's
first request on a connection decides which one applies:
PROTOCOL_VERSION in src/srgssr_mcp/_app.py names
the modern era. It is validated at import time against the installed SDK's
SUPPORTED_PROTOCOL_VERSIONS — but that list is backwards-compatible and still
contains 2024-11-05, so the membership check catches a revision being dropped,
never a drift. tests/test_protocol_version.py
holds both eras against the SDK and is the check that catches drift. Bumps are
tracked in CHANGELOG.md under the matching release.
What the server actually puts on the wire
The table above used to be an assertion held against SDK constants.
tests/test_spec_2026_07_28.py now sends real
requests through MCPServer.streamable_http_app() over httpx.ASGITransport
and asserts the answers, in both eras. What that measurement pins:
The measurement paid for itself on its first run, against 425 green tests and
96% coverage: serverInfo.version was the empty string, every tools/call
came back isError (a FastMCP 1.x ctx.info(msg, **kwargs) call shape that
mcp 2.x rejects), and eight tools refused the enum string their own published
inputSchema advertises (ConfigDict(strict=True) demands an enum instance,
which no JSON payload can carry). None of that is visible from inside the
process — which is the whole argument for testing the wire.
Update Policy
- SDK dependency updates land via Dependabot (
.github/dependabot.yml, monthly cadence, grouped under themcp-sdklabel) and run the full test suite before merge. - Spec bumps are evaluated on a feature branch against the relevant MCP SDK release; the official MCP changelog is the source of truth for breaking changes.
- A spec-version bump is always documented in
CHANGELOG.mdand, if it changes the externally observable wire contract, triggers a minor or major release per Semantic Versioning.
Project Structure
🛡️ Safety & Limits
Known Limits
- Rate Limits: SRG SSR APIs enforce rate limits — see developer.srgssr.ch for details on the tier of your OAuth2 application
- Data Freshness: EPG data may be delayed by up to 6 hours
- Historical Data: Polis data goes back to 1900 — older data is not available
- Geo-Restriction: Some streaming APIs are only available within Switzerland
- API keys required: SRG SSR APIs require free OAuth2 credentials from developer.srgssr.ch
- Non-commercial use: SRG SSR API terms restrict commercial use without explicit permission from [email protected]
- Weather coverage: SRF Meteo covers Switzerland only
Contributing
See CONTRIBUTING.md (English) · CONTRIBUTING.de.md (German)
Security
For the full security posture, vulnerability reporting process and accepted-risk register, see SECURITY.md (English) · SECURITY.de.md (German). The key egress control is summarised below.
Egress Allowlist
The server implements a code-layer egress allowlist (SEC-021, combined with SEC-004 SSRF defense) to prevent unintended external requests. Every outbound HTTP request is validated by _validate_url_safe() in src/srgssr_mcp/_http.py before it is issued.
Three controls per request:
- HTTPS-only —
http://,file://,ftp://and other non-HTTPS schemes are rejected. - Host allowlist — the URL hostname must equal
ALLOWED_HOSTS = {"api.srgssr.ch"}(exact match — subdomain tricks likeapi.srgssr.ch.attacker.exampleare blocked). One host covers everything: the OAuth2 token endpoint and every data endpoint. - IP blocklist — every resolved IP for the hostname is checked against private, loopback, link-local (incl.
169.254.169.254cloud-metadata), CGNAT, multicast and reserved ranges (IPv4 + IPv6). Any single match aborts the request — defense-in-depth against DNS rebinding.
Violations surface as ValueError and are mapped to a localized Konfigurationsfehler: … message by _handle_error, so internal network details never leak to the MCP client.
Adding a new SRG SSR domain:
- Update
ALLOWED_HOSTSinsrc/srgssr_mcp/_http.py. - Document the reason in the PR and
CHANGELOG.md. - Add a positive test case in
tests/test_unit.py(mirrortest_validate_url_safe_accepts_public_srgssr_host).
Network-Layer Egress (for future SSE/HTTP deployments): see docs/network-egress.md. For the current stdio transport, network-layer controls do not apply — the process runs in the MCP client's user context.
Logging
The server uses structured logging (OBS-003) via structlog with JSON output to stderr — keeping stdout clean for the stdio transport's JSON-RPC traffic.
Format:
- JSON-encoded events, one per line
- ISO 8601 UTC
timestampon every record - RFC 5424 severity levels:
debug,info,notice,warning,error,critical,alert,emergency - Per-call bound context:
tool,business_unit,channel_id,query, etc.
Example output:
Log levels (RFC 5424):
Configuration:
The default level is info. Override via the SRGSSR_LOG_LEVEL environment variable (debug, info, warning, error, critical):
JSON output is aggregator-friendly — pipe stderr to Datadog, Splunk, Loki, etc., and filter by structured fields (tool, business_unit, level) without regex parsing.
Testing
Changelog
See CHANGELOG.md
Data Sources & Licenses
All data exposed by this server is fetched live from a single upstream
provider, SRG SSR Public API V2 (https://api.srgssr.ch). Every tool
return is a typed Pydantic BaseModel that
embeds source / license / provenance_url / fetched_at at the top
level — so downstream consumers can record the data origin without
round-tripping through this README. The SDK exposes the corresponding
outputSchema in the tools/list manifest so MCP clients can plan
follow-up calls precisely.
Use of the SRG SSR APIs
- Non-commercial use: free, no application required.
- Commercial use: written permission required via [email protected].
This server's MIT license covers the source code only; it does not relicense the upstream data.
License
MIT License — see LICENSE
The SRG SSR APIs used in this project are subject to the SRG SSR Terms of Use.
Author
Hayal Oezkan · github.com/malkreide
Credits & Related Projects
- Data: SRG SSR Developer Portal · SRF Meteo · Polis API
- Protocol: Model Context Protocol – Anthropic / Linux Foundation
- Related:
Synergy example: "What were the results of the 2020 popular votes in Canton Zurich – and how did turnout compare to the national average?"
→ srgssr-mcp (Polis, cantonal results) + swiss-statistics-mcp (BFS, turnout data)
- Portfolio: Swiss Public Data MCP Portfolio
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):
来源:README.md,提交 42b1add
工具
0版本历史
2- v2.1.0最新Sep 20, 2026
- v2.0.1Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分