Tilastokeskus StatFin MCP Server
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., "@Tilastokeskus StatFin MCP Server What is the current unemployment rate in Finland?"
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.
Tilastokeskus StatFin MCP Server
Production-grade Model Context Protocol (MCP) server for Statistics Finland's StatFin database. Enables AI assistants like Claude to browse, search, and query Finnish statistical data.
Purpose
This project makes Finland's official statistics accessible to AI assistants through the Model Context Protocol (MCP). It bridges the gap between natural language queries and the structured PxWeb API.
Why This Exists
The Problem: Statistics Finland maintains one of the world's most comprehensive national statistics databases with 4,500+ tables covering population, employment, housing, economy, and more. However, the PxWeb API requires:
Knowledge of table IDs, variable codes, and value codes
Understanding of the hierarchical data structure
Correct query formatting with specific filter types
Awareness of API rate limits and response sizes
This makes it difficult for users to answer simple questions like "What is Helsinki's population?" without significant technical knowledge.
The Solution: This MCP server provides 7 tools that allow AI assistants to:
Discover relevant tables through natural language search
Explore the database structure and available variables
Query specific data with proper filtering and pagination
Handle rate limiting, caching, and error recovery automatically
Use Cases
Journalists asking "How has unemployment changed since COVID?"
Researchers comparing regional population trends
Analysts tracking housing price divergence between Helsinki and other cities
Citizens curious about birth rates, migration, or energy consumption
Developers building applications that need Finnish statistical data
Design Philosophy
LLM-first: Tool descriptions, parameter hints, and output schemas are optimized for AI consumption
Guided workflow: Each tool guides the LLM to the next logical step
Fail-safe: Query size estimation prevents expensive API calls; rate limiting protects against quota exhaustion
Cache-smart: Historical data is cached until StatFin updates it, minimizing redundant API calls
Related MCP server: @nor-data/statfin-mcp
Features
7 MCP Tools for comprehensive data access
149 subject areas covering population, employment, education, economy, environment, and more
~4,500+ statistical tables with decades of historical data
Smart caching with timestamp validation - historical data stays cached until updated
Rate limiting (8 req/min per instance) to respect API limits
Multi-language support (Finnish, English, Swedish)
Documentation
ARCHITECTURE.md - Technical architecture and design decisions
BLOGS.md - Blog post ideas and data stories (English)
BLOGIT.md - Blog post ideas and data stories (Finnish)
Data Source & License
Statistics Finland StatFin Database
Official statistics of Finland
Data updated regularly (varies by table)
Free to use, no API key required
Data License: Statistics Finland data is licensed under CC BY 4.0. When using the data, provide attribution: "Source: Statistics Finland"
Installation
Local Installation
Clone and build the server to run on your machine.
git clone https://github.com/your-org/statfin-mcp.git
cd statfin-mcp
npm install
npm run buildAdd to your config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"statfin": {
"command": "node",
"args": ["/absolute/path/to/statfin-mcp/dist/server.js"]
}
}
}claude mcp add statfin node /absolute/path/to/statfin-mcp/dist/server.jsVerify with:
claude mcp listAdd to ~/.codex/config.toml:
[mcp.statfin]
command = "node"
args = ["/absolute/path/to/statfin-mcp/dist/server.js"]
transport = "stdio"In Cursor settings, add MCP server with command:
Name:
statfinCommand:
nodeArgs:
/absolute/path/to/statfin-mcp/dist/server.js
Remote Server
Connect to a hosted instance without local installation.
claude mcp add --transport http statfin https://your-server.example.com/mcpVerify with:
claude mcp listAdd to your config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"statfin": {
"type": "http",
"url": "https://your-server.example.com/mcp"
}
}
}Add to ~/.codex/config.toml:
[mcp.statfin]
url = "https://your-server.example.com/mcp"
transport = "http"In Cursor settings, add MCP server:
Name:
statfinURL:
https://your-server.example.com/mcpTransport: HTTP
Running the Server
# Development mode (stdio transport, watch mode)
npm run dev
# Production HTTP server
npm start
# With custom port
PORT=8080 npm start
# Docker
docker-compose up --buildMCP Tools
Tool | Description |
| Search for tables by keyword (primary discovery) |
| Browse all 149 topic areas |
| List tables in a subject area |
| Get table structure and variables |
| Get all codes for a variable (regions, years) |
| Execute data queries |
| Check server health and rate limits |
Example Workflows
⚠️ Variable codes changed in the 8 June 2026 PxWeb migration. They are now version-stamped and table-specific (e.g.
alue_23_20260101,timeperiod_y), so the variable codes shown in the advanced examples below are illustrative — always callget_table_metadatato get the exact codes for your table. Table IDs are now short (11re.px, notstatfin_vaerak_pxt_11re.px). Value codes (SSS,KU091,MK01…) are unchanged.
Basic: Helsinki Population Trend
// Codes below are the current codes for table 11re.px (verified).
query_table({
tableId: "11re.px",
selections: [
{ variable: "alue_23_20260101", filter: "item", values: ["KU091"] }, // Helsinki
{ variable: "ikaryhma_10_20180101", filter: "item", values: ["SSS"] }, // All ages
{ variable: "sukupuoli_9_20180101", filter: "item", values: ["SSS"] }, // Total
{ variable: "timeperiod_y", filter: "top", top: 10 }, // Last 10 years
{ variable: "contentscode", filter: "item", values: ["vaerak-vaesto"] } // Population
]
})
// Returns: Helsinki population trend over the last 10 yearsAdvanced Example Queries
The variable codes in these examples are conceptual (pre-migration names shown for readability). Resolve the real, current codes for each table via get_table_metadata before querying — only the short table IDs and the value codes are guaranteed current.
Education: University Student Employment by Field
Which fields of study have the highest employment rates for students?
// Table: Student employment by education level and field
query_table({
tableId: "13g2.px",
selections: [
{ variable: "Koulutusaste", filter: "item", values: ["7"] }, // University level
{ variable: "Sukupuoli", filter: "item", values: ["SSS"] }, // All genders
{ variable: "Maakunta", filter: "item", values: ["SSS"] }, // Whole country
{ variable: "Vuosi", filter: "top", top: 3 } // Last 3 years
]
})
// Analyze: Compare IT vs humanities employment ratesHousing: Rent Price Trends by Postal Code
Track rental market changes in Helsinki city center vs suburbs
// Table: Free-market rental prices by postal code, quarterly
query_table({
tableId: "13eb.px",
selections: [
{ variable: "Postinumero", filter: "item", values: [
"00100", // Helsinki center (Kruununhaka)
"00500", // Sörnäinen
"02100", // Espoo Tapiola
"01300" // Vantaa Tikkurila
]},
{ variable: "Huoneluku", filter: "item", values: ["02"] }, // 2-room apartments
{ variable: "Vuosineljännes", filter: "top", top: 20 } // 5 years quarterly
]
})
// Analyze: Which areas are gentrifying fastest?Migration: International Migration Flows
Analyze emigration vs immigration patterns over decades
// Table: Migration by month and type
query_table({
tableId: "119z.px",
selections: [
{ variable: "Sukupuoli", filter: "item", values: ["SSS"] },
{ variable: "Tapahtumakuukausi", filter: "item", values: ["SSS"] }, // Annual totals
{ variable: "Tiedot", filter: "item", values: [
"vm41", // Immigration
"vm42", // Emigration
"vm43" // Net migration
]},
{ variable: "Vuosi", filter: "top", top: 30 } // 30-year trend
]
})
// Analyze: How has Finland's migration balance changed since 1990?Crime: Monthly Crime Statistics Trends
Track reported crimes by category with seasonal patterns
// Table: Reported crimes by month (preliminary data)
query_table({
tableId: "13jt.px",
selections: [
{ variable: "Rikosryhmä ja teonkuvauksen tarkenne", filter: "item", values: [
"101T603", // All crimes total
"101T504X406", // Violent crimes
"101T161" // Property crimes
]},
{ variable: "Tiedot", filter: "item", values: ["rikokset_lkm"] },
{ variable: "Kuukausi", filter: "top", top: 60 } // 5 years monthly
]
})
// Analyze: Seasonal crime patterns, COVID impact on crime ratesElectricity: Power Generation Mix Evolution
How has Finland's electricity production evolved toward renewables?
// Table: Electricity supply and production by source
query_table({
tableId: "11sr.px",
selections: [
{ variable: "Tiedot", filter: "item", values: [
"sahkon_tuot", // Total production
"vesivoima", // Hydropower
"tuulivoima", // Wind power
"ydinvoima", // Nuclear
"fossiiliset" // Fossil fuels
]},
{ variable: "Vuosi", filter: "top", top: 25 } // 25-year transition
]
})
// Analyze: Nuclear vs wind growth, fossil phase-out trajectoryTraffic: Road Accident Hotspots by Municipality
Which municipalities have the highest traffic accident rates?
// Table: Traffic accidents with injuries by area and road type
query_table({
tableId: "12qh.px",
selections: [
{ variable: "Alue", filter: "item", values: [
"SSS", // Whole country (for comparison)
"KU091", // Helsinki
"KU092", // Vantaa
"KU049", // Espoo
"KU837", // Tampere
"KU853" // Turku
]},
{ variable: "Tielaji", filter: "item", values: ["SSS"] },
{ variable: "Osallinen", filter: "item", values: ["SSS"] },
{ variable: "Tiedot", filter: "item", values: [
"konn", // Total accidents
"kuolonn", // Fatal accidents
"loukonn" // Injury accidents
]},
{ variable: "Vuosi", filter: "top", top: 5 }
]
})
// Analyze: Per-capita accident rates, pedestrian vs vehicle involvementHousing: Household Size and Building Type Changes
How are Finnish living patterns changing over time?
// Table: Households by size and building type
query_table({
tableId: "116a.px",
selections: [
{ variable: "Talotyyppi", filter: "item", values: [
"1", // Detached houses
"2", // Attached houses
"3", // Apartment buildings
]},
{ variable: "Asuntokunnan koko", filter: "item", values: [
"1", // 1-person households
"2", // 2-person
"3", // 3-person
"4" // 4+ person
]},
{ variable: "Vuosi", filter: "top", top: 40 } // Since 1985
]
})
// Analyze: Rise of single-person households, apartment living trendsElectric Vehicles: Adoption Rate by Vehicle Type
Track the EV transition in Finland's vehicle fleet
// Table: New vehicle registrations by fuel type
query_table({
tableId: "11ck.px",
selections: [
{ variable: "Ajoneuvoluokka", filter: "item", values: ["01"] }, // Passenger cars
{ variable: "Käyttövoima", filter: "item", values: [
"00", // Total
"01", // Petrol
"02", // Diesel
"04", // Electric
"05", // Plug-in hybrid
]},
{ variable: "Vuosi", filter: "top", top: 15 }
]
})
// Analyze: EV market share growth, diesel decline post-2015Multi-Step Analysis Patterns
Cross-Domain Analysis: Education → Employment → Income
1. Find education completion rates by field
2. Get employment statistics for recent graduates
3. Query income data by education level
4. Compare: Which fields offer best ROI?Time-Series with Regional Breakdown
1. Get national trend (region variable, value "SSS")
2. Compare major cities (KU091, KU837, KU853)
3. Identify regional divergence patterns
4. Correlate with local economic indicatorsDemographic Shift Analysis
1. Query population by age groups (1990-2024)
2. Get migration data for same period
3. Query birth/death rates
4. Model: Aging population impact on workforceCommon Region Codes
Code | Description |
| Whole country (KOKO MAA) |
| Regions (maakunta) |
| Helsinki |
| Vantaa |
| Espoo |
Development
# Type checking
npm run typecheck
# Run unit tests
npm run test:run
# Run tests with coverage
npm run test:coverage
# Run integration tests (requires API access)
npm run test:integration
# Fetch fresh test fixtures
npm run test:fixtures:fetchEnvironment Variables
Variable | Default | Description |
| 8080 | HTTP server port |
| stdio | Set to "http" for HTTP transport |
| - | Optional authentication token |
| info | Logging level (debug, info, warn, error) |
API Rate Limits
StatFin API: 30 requests/minute total
This server: 8 requests/minute per instance
Designed for up to 3 concurrent Cloud Run instances
License
This project (code) is licensed under MIT. The statistical data accessed through this server is provided by Statistics Finland under CC BY 4.0.
Available Tools
7 toolsget_api_statusCheck API StatusARead-onlyIdempotent
Get server health, rate limit status, and cache statistics.
Use when:
Queries are failing or slow
Need to check remaining API quota
Debugging connection issues
Rate limit: 8 requests per minute per instance.
Inputs: no named parameters. Returns: cache, config, healthy, rateLimit
get_table_metadataGet Table StructureARead-onlyIdempotent
Get the structure of a table: what variables it has and what values are available.
REQUIRED before querying - shows you:
Variable codes (table-specific and version-stamped, e.g. "alue_23_20260101" for region, "timeperiod_y" for the time variable). Always read these here - never assume or reuse codes from another table.
Value codes (KU091=Helsinki, SSS=Total, 2024=year 2024)
Which variables are required vs optional
Total possible data combinations
Example: a region variable may have 300+ values, a year variable 50+.
After understanding the structure, use query_table with the exact codes from this output.
Inputs: tableId (required), language, includeAllValues. Returns: title, tableId, variables, lastUpdated, +2 more
get_variable_valuesGet All Values for a VariableARead-onlyIdempotent
Get the complete list of values for a variable when metadata only shows first 20.
Useful for:
Finding specific region codes (KU091=Helsinki, MK01=Uusimaa region)
Getting all available years (1972-2024)
Finding specific category codes
Common region codes:
SSS = Whole country (Finland)
MK01-MK19 = Regions (maakunta)
KU091 = Helsinki, KU049 = Espoo, KU837 = Tampere
Use search parameter to filter: search="Helsinki" returns only matching values.
Inputs: tableId (required), variable (required), search, language. Returns: total, values, variable, commonCodes
list_subject_areasBrowse Statistical TopicsARead-onlyIdempotent
List all 149 subject areas (topics) in StatFin database.
Use this to explore what statistics are available when you don't have a specific search term.
Topic examples:
vaerak: Population structure
tyti: Labor force
ashi: Housing prices
synt: Births and deaths
muutl: Migration
After finding an area, use list_tables to see all tables in that topic.
Inputs: language. Returns: areas, total
list_tablesList Tables in TopicARead-onlyIdempotent
List all statistical tables within a subject area.
Each area typically has 20-40 tables with different data views.
Common subject areas:
"vaerak" → 30+ population tables (age, gender, region, etc.)
"tyti" → 35+ employment tables (employment rate, unemployment, etc.)
"ashi" → 15+ housing price tables
Use list_subject_areas first to find the area ID, or use search_statistics for direct search.
Inputs: subjectArea (required), language. Returns: total, tables, subjectArea
query_tableQuery Statistical DataARead-onlyIdempotent
Execute a query to retrieve actual statistical data from a table.
WORKFLOW: search_statistics → get_table_metadata → query_table
Selection types:
filter: "item" + values: ["KU091", "2024"] → specific values
filter: "top" + top: 5 → latest 5 values (good for time variables)
filter: "all" → all values (use carefully, can be large!)
Example - Helsinki population for last 5 years (the variable codes below are from table 11re.px; YOUR table's codes WILL differ - always read them from get_table_metadata first, never reuse these): { "tableId": "11re.px", "selections": [ {"variable": "alue_23_20260101", "filter": "item", "values": ["KU091"]}, {"variable": "timeperiod_y", "filter": "top", "top": 5}, {"variable": "sukupuoli_9_20180101", "filter": "item", "values": ["SSS"]}, {"variable": "ikaryhma_10_20180101", "filter": "item", "values": ["SSS"]}, {"variable": "contentscode", "filter": "item", "values": ["vaerak-vaesto"]} ] }
IMPORTANT: Variable codes are table-specific; get them from get_table_metadata. Use VALUE CODES (KU091, SSS), not labels (Helsinki, Total).
Inputs: tableId (required), selections (required), limit, language. Returns: data, error, success, metadata, +2 more
search_statisticsSearch Finnish StatisticsARead-onlyIdempotent
Search Statistics Finland's StatFin database for statistical tables by keyword.
USE THIS FIRST when looking for data. Returns ranked results with relevance scores.
Examples:
"väestö Helsinki" → population tables for Helsinki
"unemployment" → employment/labor market tables
"housing prices" → real estate statistics
Returns: tableId (needed for query_table), title, relevance score, publication date.
After finding a table, use get_table_metadata to see its structure before querying.
Inputs: query (required), limit, language. Returns: query, total, hasMore, results
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a clearly distinct purpose: search, list topics, list tables, get metadata, get variable values, query data, and check status. No overlaps or ambiguous boundaries; the workflow is explicitly sequential and each step is unique.
All tool names follow a consistent verb_noun snake_case pattern: search_statistics, list_subject_areas, list_tables, get_table_metadata, get_variable_values, query_table, get_api_status. Predictable and uniform.
With 7 tools, the server is well-scoped for a statistical database access. Each tool is essential and earns its place—no redundant or missing operations. The count is comfortably within the optimal 3-15 range.
The toolset covers the entire lifecycle from discovery (search, list subject areas, list tables) to detailed exploration (metadata, variable values) to data retrieval (query) and system status. No significant gaps; the workflow is fully supported.
Maintenance
Related MCP Connectors
Experimental MCP exploring Statistics Finland PxWeb statistical datasets.
MCP server for Statistics Sweden (SCB) - 1200+ tables with population, economy, environment data
Hosted MCP server exposing US hospital procedure cost data to AI assistants
Related MCP Servers
- AlicenseBqualityDmaintenanceMCP server for accessing Japanese government statistics portal 'e-Stat' API, enabling language models to search and retrieve statistical data.587 PyPI21MIT
- AlicenseAqualityDmaintenanceMCP server for official statistics from Statistics Finland (Tilastokeskus) — the StatFin database, exposed through the PxWeb API. Search 3000+ tables, inspect their dimensions, and pull data as JSON-stat2.457 npmMIT
- AlicenseAqualityDmaintenanceMCP server for accessing statistical data via the PxWeb API v2.63MIT
- AlicenseAqualityCmaintenanceLocal MCP server for querying Polish socioeconomic statistics from the GUS Bank Danych Lokalnych (BDL), letting AI find variables and units and pull data.5MIT