SCB MCP
Connect LLMs or AI-chatbots to let them query and interact with official data and statistics from SCB (Sweden Statistics)
đ SCB MCP Server
SCB MCP Àr server som LLM:s och AI-chatbotar kan anvÀnda för att söka, hitta och hÀmta officiell data och statistik frÄn StatistikbyrÄn (SCB). Det omfattar 1 200+ statistiktabeller med data om befolkning & demografi, ekonomi & finans, miljö, arbetsmarknad, utbildning och transport. Perfekt för att bygga interaktiva instrumentpaneler, forskningsverktyg och utbildningsapplikationer.
Ăversikt
The SCB MCP server provides seamless integration with Statistics Sweden's PxWebAPI 2.0, enabling LLM:s to access:
- Population & Demographics: Regional data, migrations, births, deaths (312+ regions)
- Economy & Finance: GDP, taxes, business statistics, national accounts
- Environment: Greenhouse gas emissions, water/waste management, sustainability metrics
- Labor Market: Employment, unemployment, occupational data, skills matching
- Education: Student statistics, course enrollments, skills development
Data ranges from 1950s to present (monthly/quarterly updates). Real-time population statistics updated to November 2025.
- Befolkning & demografi: Regionaldata, migrationer, födslar, dödsfall (312+ regioner)
- Ekonomi & finans: BNP, skatter, företagsstatistik, nationalrÀkenskaper
- Miljö: VÀxthusgaser, vatten/avfallshantering, hÄllbarhetsvÀrdena
- Arbetsmarknad: SysselsÀttning, arbetslöshet, yrkesdata, kompetensmatchning
- Utbildning: Studentstatistik, kursanmÀlningar, kompetensutveckling
| Feature | Description |
|---|---|
| Comprehensive Access | 1,200+ tables, 312+ regions, 75+ years of historical data |
| Smart Querying | Natural language search, region code resolution ("Lerum" â 1441), TOP() & wildcard support |
| Fuzzy Matching | "Goteborg" matches "Göteborg", "Malmo" matches "Malmö" |
| Developer-Friendly | Full documentation, clear errors with suggestions, selection validation, metadata in responses |
| Production-Ready | Rate limiting (30 req/10s), consistent behavior, proper data types, language support (SV/EN) |
| Swedish by Default | All tools use Swedish (sv) as default for best search results |
| Real-Time Data | Monthly/quarterly updates, population data to November 2025 |
Huvudfunktioner
| Funktion | Beskrivning |
|---|---|
| Omfattande Ätkomst | 1 200+ tabeller, 312+ regioner, 75+ Ärs historiska data |
| Smart sökning | NatursprĂ„kig sökning, regionkodupplösning ("Lerum" â 1441), TOP() & wildcard-stöd |
| Fuzzy matching | "Goteborg" matchar "Göteborg", "Malmo" matchar "Malmö" |
| UtvecklarvÀnlig | FullstÀndig dokumentation, tydliga felmeddelanden, valideringsmöjligheter, metadata i svaren |
| Produktionsklar | Rate limiting (30 req/10s), konsekvent beteende, rÀtt datatyper, sprÄkstöd (SV/EN) |
| Svenska som standard | Alla verktyg anvÀnder svenska (sv) som default för bÀsta sökresultat |
| Aktuell data | MÄnatliga/kvartalsvisa uppdateringar, befolkningsdata till november 2025 |
đ Snabbstart
Enklaste sĂ€ttet: AnvĂ€nd den redan hostade servern â ingen installation behövs!
MCP remote URL: https://scb-mcp.onrender.com/mcp
LÀgg till denna konfiguration i din MCP-vÀrd:
{
"mcpServers": {
"scb": {
"type": "http",
"url": "https://scb-mcp.onrender.com/mcp"
}
}
}
â Klart! Du har nu tillgĂ„ng till alla 1 200+ svenska statistiktabeller.
Easiest way: Use the already hosted server â no installation needed!
MCP remote URL: https://scb-mcp.onrender.com/mcp
Add this configuration to your MCP host:
{
"mcpServers": {
"scb": {
"type": "http",
"url": "https://scb-mcp.onrender.com/mcp"
}
}
}
â Done! You now have access to all 1,200+ Swedish statistical tables.
Installation & instÀllning
Alternativ 1: Remote URL (ingen installation)
AnvÀnd den hostade servern direkt - fungerar med alla MCP-kompatibla klienter:
URL: https://scb-mcp.onrender.com/mcp
| Klient | Hur du ansluter |
|---|---|
| GitHub Copilot (VS Code) | LĂ€gg till i .vscode/mcp.json (se nedan) |
| ChatGPT (Dev Mode) | LĂ€gg till MCP server URL: https://scb-mcp.onrender.com/mcp |
| Claude Web | LĂ€gg till MCP server: https://scb-mcp.onrender.com/mcp |
| Gemini | Konfigurera HTTP MCP endpoint |
| Custom | POST till /mcp med JSON-RPC 2.0 |
GitHub Copilot (VS Code)
Skapa .vscode/mcp.json i ditt projekt:
{
"servers": {
"scb": {
"type": "http",
"url": "https://scb-mcp.onrender.com/mcp"
}
}
}
Eller anvÀnd Command Palette: MCP: Add Server och vÀlj HTTP-typ.
Ingen autentisering krÀvs. CORS Àr aktiverat för alla domÀner.
Alternativ 2: Lokal installation (Node.js)
För Claude Code, terminal-klienter eller egen hosting:
# Klona repository
git clone https://github.com/isakskogstad/SCB-MCP.git
cd SCB-MCP
# Installera och bygg
npm install
npm run build
Claude Code (CLI)
claude mcp add scb-mcp -- node /sökvÀg/till/SCB-MCP/dist/index.js
MCP-konfiguration (stdio)
LĂ€gg till i ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"scb": {
"command": "node",
"args": ["/sökvÀg/till/SCB-MCP/dist/index.js"],
"type": "stdio"
}
}
}
Kör egen HTTP-server
npm run start # Startar pÄ port 3000
# eller
PORT=8080 npm run start
Alternativ 3: Docker
docker build -t scb-mcp .
docker run -p 3000:3000 scb-mcp
Option 1: Remote URL (no installation)
Use the hosted server directly - works with all MCP-compatible clients:
URL: https://scb-mcp.onrender.com/mcp
| Client | How to connect |
|---|---|
| ChatGPT (Dev Mode) | Add MCP server URL: https://scb-mcp.onrender.com/mcp |
| Claude Web | Add MCP server: https://scb-mcp.onrender.com/mcp |
| Gemini | Configure HTTP MCP endpoint |
| Custom | POST to /mcp with JSON-RPC 2.0 |
No authentication required. CORS enabled for all origins.
Option 2: Local installation (Node.js)
For Claude Code, terminal clients or self-hosting:
git clone https://github.com/isakskogstad/SCB-MCP.git
cd SCB-MCP
npm install
npm run build
Claude Code (CLI)
claude mcp add scb-mcp -- node /path/to/SCB-MCP/dist/index.js
MCP configuration (stdio)
Add to ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"scb": {
"command": "node",
"args": ["/path/to/SCB-MCP/dist/index.js"],
"type": "stdio"
}
}
}
Run your own HTTP server
npm run start # Starts on port 3000
# or
PORT=8080 npm run start
Option 3: Docker
docker build -t scb-mcp .
docker run -p 3000:3000 scb-mcp
AnvÀndarguide
1. Sök efter statistiktabeller
# Hitta befolkningsrelaterade tabeller
results = scb.search_tables(query="befolkning statistik", limit=10)
# Filtrera efter kategori
results = scb.search_tables(query="miljö", category="environment", limit=5)
1. Search for statistical tables
results = scb.search_tables(query="population", limit=10)
results = scb.search_tables(query="environment", category="environment", limit=5)
2. Hitta regionkoder
# Lerum kommun
region = scb.find_region_code(query="Lerum")
# Returnerar: code="1441", name="Lerum"
# Större regioner
region = scb.find_region_code(query="Stockholm")
# Returnerar: code="01" (lÀn), code="0180" (kommun)
# Fuzzy matching - fungerar utan svenska tecken
region = scb.find_region_code(query="Goteborg")
# Returnerar: code="1480", name="Göteborg"
region = scb.find_region_code(query="Lerum")
region = scb.find_region_code(query="Stockholm")
# Fuzzy matching - works without Swedish characters
region = scb.find_region_code(query="Goteborg")
# Returns: code="1480", name="Göteborg"
3. HĂ€mta data
# MedelÄlder i Lerum 2024
data = scb.get_table_data(
tableId="TAB637",
selection={
"Region": ["1441"],
"Kon": ["1+2"],
"Tid": ["2024"],
"ContentsCode": ["BE0101G9"]
}
)
# Resultat: MedelÄlder i Lerum 2024: 40.1 Är
data = scb.get_table_data(
tableId="TAB637",
selection={
"Region": ["1441"],
"Kon": ["1+2"],
"Tid": ["2024"],
"ContentsCode": ["BE0101G9"]
}
)
Best practices
| Problem | Lösning |
|---|---|
| Stor datamÀngd? | AnvÀnd alltid preview_data() först för att testa |
| För mycket data? | AnvÀnd "TOP(5)" istÀllet för "*" för tidsperioder |
| Felaktiga koder? | Anropa get_table_variables() först â koder varierar mellan tabeller |
| OsÀker pÄ enheter? | Kontrollera variabeletikett för enheter (kt, ton, procent osv.) |
| Issue | Solution |
|---|---|
| Large dataset? | Always use preview_data() first to test |
| Too much data? | Use "TOP(5)" instead of "*" for time periods |
| Wrong codes? | Call get_table_variables() first â codes vary between tables |
| Unsure about units? | Check variable label for units (kt, tonnes, percent, etc.) |
Praktiska exempel
Ex: Befolkningstrend Lerum vs Stockholm
# JÀmför tvÄ regioner över tid
data = scb.get_table_data(
tableId="TAB637",
selection={
"Region": ["1441", "0180"], # Lerum och Stockholm
"Kon": ["1+2"],
"Tid": ["TOP(5)"],
"ContentsCode": ["BE0101G9"]
}
)
# Stockholm: 41.0 Är (2024), Lerum: 40.1 Är (2024)
# Trend: Stockholm Äldras snabbare
data = scb.get_table_data(
tableId="TAB637",
selection={
"Region": ["1441", "0180"], # Lerum and Stockholm
"Kon": ["1+2"],
"Tid": ["TOP(5)"],
"ContentsCode": ["BE0101G9"]
}
)
# Stockholm: 41.0 years (2024), Lerum: 40.1 years (2024)
Resurser
- SCB-databas: https://www.scb.se/
- API-dokumentation: https://www.scb.se/en/services/open-data-api/pxwebapi/
- Dataexplorer: https://pxweb.scb.se/pxweb/en/
Av: Isak Skogstad
Related Servers
Mina Archive Node API
Access Mina blockchain data, including events, actions, and network state, through the Mina Archive Node API.
ADO.NET MCP Server
A C# MCP server for interacting with databases via ADO.NET, compatible with Virtuoso.
pg-aiguide
Postgres skills and documentation to help AI coding tools generate better PostgreSQL code.
MCP Postgres Query Server
An MCP server for querying a PostgreSQL database in read-only mode.
MariaDB
An MCP server for retrieving data from a MariaDB database.
OSV Database
An MCP server for querying the OSV (Open Source Vulnerability) database API.
Gralio SaaS Database
Access a comprehensive database of over 30,000 SaaS products, including reviews, pricing, alternatives, and growth metrics.
Dune Analytics
Access Dune Analytics data for AI agents, including DEX metrics, EigenLayer stats, and Solana token balances.
PostgreSQL
Provides read-only access to PostgreSQL databases, allowing LLMs to inspect schemas and execute queries.
Canteen Data
Query employee canteen dining data, providing breakfast and lunch attendance statistics within a specified date range.