Statistics Sweden’s open data made available as an MCP server
Project description
MCP Server for Statistics Sweden (SCB) API
A FastMCP server that provides access to Statistics Sweden's PxWebApi v2, offering statistical tables covering employment, labor costs, wages, and other civil data from Sweden.
Features
- Table Discovery: Browse and search 5,155 statistical tables
- Data Retrieval: Fetch statistical data with optional filtering
- Codelists: Access code lists for valid filter values
- Saved Queries: Save and retrieve frequently used queries
- Pagination: Handle large result sets efficiently
- Language Support: English and Swedish
- Error Handling: Robust error handling with retry logic
Installation
Prerequisites
- Python 3.11 or higher
- pip or uv package manager
Install from PyPI
pip install scb-opendata-mcp
# Or with uv
uvx scb_opendata_mcp
Install from source
# Clone the repository
git clone https://github.com/ashwinvis/scb-opendata-mcp.git
cd scb-opendata-mcp
# Install dependencies
pip install .
# Or with uv
uv sync
Usage
Running the server
The package on installation
scb_opendata_mcp
# Or with uv
uv run scb_opendata_mcp
See scb_opendata_mcp --help for available options. An stdio transport mechanism also exists.
Fallback option
uv run fastmcp run src/scb_opendata_mcp/server.py -t http # HTTP server
Configuration for common agent harnesses
Claude Code
claude mcp add --scope user --transport http scb_opendata_mcp http://localhost:6767
Mistral Vibe
In ~/.vibe/config.toml or ~/.vibe/agents/name_of_agent.toml:
[[mcp_servers]]
name = "scb_opendata_mcp"
transport = "http"
url = "http://localhost:6767/mcp"
OpenCode
In ~/.config/opencode/opencode.jsonc:
{
"mcp": {
"scb_opendata_mcp": {
"type": "remote",
"url": "https://localhost:6767/mcp",
"enabled": true
}
}
}
Tools Available
Table Discovery
list_tables()- List all available statistical tables with paginationget_table_metadata(table_id)- Get detailed metadata including variablessearch_tables(query)- Convenience wrapper overlist_tables, to search tables by name or description
Data Retrieval
get_table_data(table_id, filters)- Fetch data with optional filteringget_table_default_selection(table_id)- Get default data selection for a table
Codelist Tools
list_codelists(table_id)- List all available codelists for the tableget_codelist(codelist_id)- Get specific codelist details
Saved Query Tools
get_saved_query(query_id)- Get a saved query including data and selection criteriaget_saved_query_data(query_id)- Get data from a specific saved queryget_saved_query_selection(query_id)- Get the selection query used in a specific saved querysave_query(table_id, selection)- Save a data querydelete_saved_query(query_id)- Delete a saved query
Development
Running Tests
uv run pytest
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
Support
For issues or questions:
- Review the OpenAPI specification or alternatively from https://github.com/PxTools/PxApiSpecs/blob/master/PxAPI-2.yml.
- Visit Statistics Sweden API documentation:
SCB Open Data Skills
This is an unofficial companion repository SCB Open Data Skills that provides skill definitions for accessing Statistics Sweden's data through this MCP server. These skills are designed to work with major coding agent tools and provide workflows for various statistical domains.
Disclaimer
This is an unofficial tool. The code was generated using AI while using official documents and the API specification as context. Tests are also added to verify the functionality. A thorough rigorous verification test is recommended before using it in any serious application.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scb_opendata_mcp-0.2.1.tar.gz.
File metadata
- Download URL: scb_opendata_mcp-0.2.1.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e0081ad65588cc09434a9c1909835c615e4699f9235c8b6050c91b754e2b3bd
|
|
| MD5 |
5beff123a083d0e7ddf3ef2a984e93a6
|
|
| BLAKE2b-256 |
7da40f15b811aaf90328d99fc42b94f1e52c9f8d8e8609453a464fa736de183a
|
File details
Details for the file scb_opendata_mcp-0.2.1-py3-none-any.whl.
File metadata
- Download URL: scb_opendata_mcp-0.2.1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
425fee60d5b1c2b6e79872cd9dc94446cf8363ed2d01a48a5d683a431a1d86d0
|
|
| MD5 |
8c91a2391ca263a0362be3c1df9ae40d
|
|
| BLAKE2b-256 |
be82be248a36f57a3ec98e9a7b9a41ed8b4d566f1c10fb3a2efa221aa9365fc7
|