SCB MCP Server
Enables LLMs to search, access, and retrieve official Swedish statistics from Statistics Sweden (SCB), providing access to 1,200+ tables covering demographics, economy, environment, labor market, and education with 75+ years of historical data.
README
<img width="640" height="320" alt="MCP SERVER" src="https://github.com/user-attachments/assets/8183270f-cc19-4513-a26b-c8c18e60f1d8" />
đ 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
<details> <summary><strong>đŹđ§ Overview </strong></summary>
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.
</details> SCB MCP-servern ger sömlös integrering med StatistikbyrÄns (SCB) PxWebAPI 2.0, vilket gör det möjligt för LLM:s att tillgÄ:
- 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
<details> <summary><strong>đŹđ§ Key features (English)</strong></summary>
| 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 |
</details>
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.
<details> <summary><strong>đŹđ§ Quick start (English)</strong></summary>
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.
</details>
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
<details> <summary><strong>đŹđ§ Installation & setup (English)</strong></summary>
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
</details>
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)
<details> <summary><strong>đŹđ§ Usage guide (English)</strong></summary>
1. Search for statistical tables
results = scb.search_tables(query="population", limit=10)
results = scb.search_tables(query="environment", category="environment", limit=5)
</details>
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"
<details> <summary><strong>đŹđ§ Resolve region codes (English)</strong></summary>
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"
</details>
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
<details> <summary><strong>đŹđ§ Fetch data (English)</strong></summary>
data = scb.get_table_data(
tableId="TAB637",
selection={
"Region": ["1441"],
"Kon": ["1+2"],
"Tid": ["2024"],
"ContentsCode": ["BE0101G9"]
}
)
</details>
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.) |
<details> <summary><strong>đŹđ§ Best practices (English)</strong></summary>
| 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.) |
</details>
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
<details> <summary><strong>đŹđ§ Example 1: Population trends (English)</strong></summary>
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)
</details>
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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.