statsbudget-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@statsbudget-mcpShow me the budget overview for 2024"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
statsbudget-mcp
Status: Alpha (v0.1.0) This project is under active development. APIs, schemas, and output formats may change without notice. Not recommended for production use yet. Contributions and feedback welcome.
MCP server for the Swedish national budget (statsbudgeten). Provides structured, queryable access to budget outturn (utfall), tax revenue, tax quota analysis, and fiscal data.
Built for Claude Desktop, Glama, and any MCP-compatible client.
Important: Data Semantics
Budget tools return actual outturn (utfall) from Statskontoret, not the originally proposed budget. This means the numbers show what was actually spent and collected, not what was planned. Every response includes data_type and source fields so consuming applications can communicate this clearly.
Related MCP server: Kolada MCP Server
Sync Guarantees
Atomic snapshots: both expenditure and income must parse successfully before any in-memory data or cache is updated. If either dataset fails, the server raises
SyncErrorand falls back to the previous valid cache.Income revision selection: when multiple income revisions are available (Preliminar 1, 2, 3, Definitiv), the sync picks the highest-priority revision (definitiv > preliminar 3 > 2 > 1), not the first one in DOM order. The selected revision is exposed in sync metadata.
Streaming downloads: files are downloaded with a streaming byte counter and
Content-Lengthearly check. The full response is never buffered before enforcing the 50 MB limit.Startup fallback: if sync fails at startup, the server falls back to a stale but complete cache. If no cache exists, it starts empty and logs the error.
Data Sources
Source | What | Format | Coverage |
SCB PxWeb API | Tax revenue by type, tax quota/GDP | JSON (POST) | 1950-2025 |
Statskontoret Oppna Data | Budget outturn per expenditure area | CSV in ZIP | 2006-2025 |
MCP Tools (14)
Budget Outturn (4)
get_budget_overview(year): actual expenditure outturn, total income, balance, all 27 areas (MSEK)get_expenditure_area(area_id, year): drill-down into appropriations with budget vs outturncompare_budgets(year_a, year_b): year-over-year outturn delta per areasync_budget_data(year?): download and cache latest outturn from Statskontoret
Tax Revenue (3)
get_revenue(year): tax revenue by category (labour, capital, consumption) in MSEKget_revenue_timeseries(from_year, to_year): revenue over time by categoryget_revenue_detail(year, tax_types?): full 40-category breakdown
Tax Quota Analysis (3)
get_laffer_data(from_year?, to_year?): tax quota (% of GDP) as timeseries with decade tags and reform annotationsget_laffer_timeseries(from_year?, to_year?): flat timeseries with nominal GDP growth and reform markersget_tax_reforms(): annotated Swedish tax reforms (1971-2020)
Meta (4)
get_sync_status(): data freshness, selected income revision, and cache diagnosticsget_publication_schedule(): when Statskontoret publishes new dataget_available_years(): years with loaded outturn dataget_cache_stats(): SQLite cache diagnostics
Resources
budget://areas: all 27 expenditure areas (id, name)
Installation
# Development
git clone https://github.com/bjornwalther/statsbudget-mcp.git
cd statsbudget-mcp
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
# Run the server
statsbudget-mcpClaude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"statsbudget-mcp": {
"command": "python",
"args": ["-m", "statsbudget_mcp.server"]
}
}
}Development
# Run tests (unit only)
pytest tests/ -m "not integration"
# Run all tests including SCB API integration
pytest tests/
# Lint
ruff check src/ tests/Architecture
src/statsbudget_mcp/
|-- __init__.py # Package version
|-- server.py # FastMCP server, 14 tools, lifespan with auto-cache
|-- scb_client.py # SCB PxWeb API client (async, retry with backoff)
|-- statskontoret.py # Statskontoret client (scrape, revision select, streaming download)
|-- laffer.py # Tax quota analysis with reform annotations
|-- cache.py # SQLite cache (schema-versioned, atomic snapshots, dual-dataset validation)
|-- formatters.py # ASCII visualization (bars, flow, decision chain, Laffer)Roadmap
SCB tax revenue and quota client
Statskontoret budget outturn client
Tax quota analysis module with reform annotations
SQLite cache with schema versioning and atomic snapshots
FastMCP server with 14 tools
ASCII formatters (bars, flow, decision, comparison, Laffer timeline)
Retry logic with exponential backoff
Download/ZIP size limits and host allowlist
Atomic staged sync with SyncError fallback
Income revision selection (definitiv > preliminar)
Streaming download with size enforcement
Publish to PyPI (
uvx statsbudget-mcp)Riksdagen voting client (propositions, votes per party)
Taxpayer breakdown by income source (5-level drill-down with legislative history)
Laffer #2: corporate tax (statutory rate vs revenue/GDP)
Laffer #3: marginal income tax (Pomperipossa analysis)
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Riksdagen (Swedish Parliament) open data MCP.
Query US Treasury national debt, interest rates, exchange rates, and fiscal datasets via MCP.
MCP server for Statistics Sweden (SCB) - 1200+ tables with population, economy, environment data
Access U.S. congressional data - bills, votes, members, committees - via MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides access to 5,000+ Key Performance Indicators across 264 operating areas for all Swedish municipalities and regions, enabling statistical analysis, comparisons, and trend tracking of Swedish public sector data.213412MIT
- AlicenseNot gradedqualityCmaintenanceProvides access to Sweden's comprehensive municipal and regional statistics database with semantic search capabilities. Enables natural language queries against thousands of Key Performance Indicators covering various aspects of Swedish public sector data.16Apache 2.0
- AlicenseNot gradedqualityCmaintenanceAn MCP server that provides tools for querying Swedish monetary-policy data from Sveriges Riksbank, including GDP, unemployment, CPI, and policy rates, enabling LLMs and clients to fetch economic indicators and forecasts.2Apache 2.0
- FlicenseNot gradedqualityCmaintenanceEnables LLMs to query and retrieve real-time open data, documents, protocols, and records from the Swedish Parliament (Riksdag) and Government Offices through 32 specialized MCP tools.30-