Skip to main content

MCP server for Swiss direct democracy data: Swissvotes (1848+), BFS opendata.swiss, SRGSSR Polis (1900+)

Project description

swiss-democracy-mcp

CI PyPI Python License: MIT Swiss Public Data MCP

Part of the Swiss Public Data MCP Portfolio — connecting AI models to Swiss institutional data sources.

An MCP server providing access to Swiss direct democracy data, covering all federal popular votes since 1848 and elections since 1900.


Demo Query

«Wie hat der Kanton Zürich bei der AHV 21 Initiative 2022 abgestimmt,
 und welche Parteien unterstützten die Vorlage?»

democracy_search_votes(keyword="AHV 21", year_from=2022)
democracy_get_cantonal_results(vote_number="551")
democracy_get_party_positions(vote_number="551")


Data Sources

Source Coverage Auth
Swissvotes (Uni Bern) All federal votes since 1848 · 874 columns · party positions · cantonal results None ✓
BFS / opendata.swiss Real-time & archive (since 1981) · municipality level None ✓
SRGSSR Polis Votes & elections since 1900 · municipality detail OAuth2 key

Tools

Phase 1 — Swissvotes (No Auth Required)

Tool Description
democracy_search_votes Search all federal popular votes since 1848 by keyword, date range, legal form, outcome, policy domain
democracy_get_vote_detail Full details for a specific vote: official title, parliamentary positions, national result, signatures
democracy_get_party_positions Party recommendations (FDP, SP, SVP, Die Mitte, GPS, GLP, …) with campaign finance data
democracy_get_cantonal_results Results for all 26 cantons: yes%, turnout, accepted flag
democracy_list_vote_dates List all voting dates with number of proposals per date

Phase 2 — BFS Real-Time (No Auth Required)

Tool Description
democracy_bfs_list_vote_dates List all BFS voting dates (archive + current)
democracy_bfs_get_vote_results Real-time or archived results at national, cantonal, or municipality level

Phase 3 — SRGSSR Polis (API Key Required)

Tool Description
democracy_polis_list_votations Historical votations since 1900 with municipality-level data
democracy_polis_get_votation_detail Full Polis detail, optionally with all municipality results
democracy_polis_list_elections National Council, Council of States, and cantonal elections since 1900

Installation

Claude Desktop (stdio)

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "swiss-democracy": {
      "command": "uvx",
      "args": ["swiss-democracy-mcp"],
      "env": {
        "SRGSSR_CONSUMER_KEY": "your_key_here",
        "SRGSSR_CONSUMER_SECRET": "your_secret_here"
      }
    }
  }
}

The SRGSSR_* variables are optional. Without them, all Swissvotes and BFS tools remain fully functional. Only the Polis tools require credentials.

Cloud / Render.com (Streamable HTTP)

pip install swiss-democracy-mcp
MCP_TRANSPORT=streamable_http MCP_PORT=8000 python -m swiss_democracy_mcp.server

Architecture

┌─────────────────────────────────────────────┐
│              Claude / LLM Host              │
└──────────────┬──────────────────────────────┘
               │ MCP (stdio / Streamable HTTP)
┌──────────────▼──────────────────────────────┐
│         swiss-democracy-mcp                 │
│                                             │
│  ┌─────────────────────────────────────┐   │
│  │  Swissvotes CSV Cache (24h TTL)     │   │
│  │  All 874 columns, since 1848        │   │
│  └──────────────┬──────────────────────┘   │
│                 │                           │
│  ┌──────────────▼──────────────────────┐   │
│  │  BFS / opendata.swiss (no auth)     │   │
│  │  Real-time & archive since 1981     │   │
│  └──────────────┬──────────────────────┘   │
│                 │                           │
│  ┌──────────────▼──────────────────────┐   │
│  │  SRGSSR Polis (OAuth2, optional)    │   │
│  │  Votes & elections since 1900       │   │
│  └─────────────────────────────────────┘   │
└─────────────────────────────────────────────┘

Transport: stdio for Claude Desktop · Streamable HTTP for cloud/Render.com
Auth pattern: No-Auth-First — Swissvotes & BFS work without any credentials
Cache: Swissvotes CSV is loaded once at startup and cached for 24 hours


Portfolio Synergy

Combine with other servers in the Swiss Public Data MCP portfolio:

Example multi-server query:
«Vergleiche die Abstimmungsresultate zur AHV-Reform mit der Altersstruktur der Kantone»
swiss-democracy-mcp + swiss-statistics-mcp


Known Limitations

  • Swissvotes coverage: Cantonal-level results are available since 1848; municipality-level results only via SRGSSR Polis (since ~1990s depending on the vote).
  • BFS archive: Real-time service covers federal votes since 1981 only.
  • Polis tools: Require free registration at developer.srgssr.ch. Non-commercial use only.
  • CSV cache: The Swissvotes dataset is ~several MB and is cached in memory for 24 hours. Memory footprint is accordingly higher than API-only servers.

Testing

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

# Live tests (require network access)
PYTHONPATH=src pytest tests/ -m "live" -v

Contributing

See CONTRIBUTING.md.


License

MIT — see LICENSE.

Data licenses:

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_democracy_mcp-0.1.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

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

swiss_democracy_mcp-0.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file swiss_democracy_mcp-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for swiss_democracy_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e491402ff9f70d0e47acb9ca6170e3c71f807e71eb3712839af1260a035ba852
MD5 7fad348fff9d5bdfb5376eca67135824
BLAKE2b-256 8aa8d5aedacabe878ab6f0dc1957c57e89dbaed39617ef81853059aa43e291d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for swiss_democracy_mcp-0.1.0.tar.gz:

Publisher: publish.yml on malkreide/swiss-democracy-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_democracy_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for swiss_democracy_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c75d9d36bed3ff1ed698b0eb9942b233f51b2195d92f6a553f85cca3467ab61
MD5 59c5dfab5be1350262ed123072fa5cbd
BLAKE2b-256 4ac4b69f511b540d5471168f6116a715a9825a6c4b139abccc1b9030014cbf42

See more details on using hashes here.

Provenance

The following attestation bundles were made for swiss_democracy_mcp-0.1.0-py3-none-any.whl:

Publisher: publish.yml on malkreide/swiss-democracy-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