trafikverket-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., "@trafikverket-mcp What's the weather on E4?"
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.
Trafikverket MCP Server
A Model Context Protocol (MCP) server providing real-time access to Swedish road weather, traffic cameras, road conditions, and traffic flow data from Trafikverket (Swedish Transport Administration).
Features
Real-time weather data from 850+ Swedish road weather stations
Traffic camera access with live images and geographic search
Traffic situations including accidents, roadwork, and closures
Traffic flow data with vehicle counts and average speeds
Road surface conditions including ice, snow, and water depth
Geographic proximity search for cameras and weather stations
County-based filtering for regional queries
Related MCP server: aria-mcp-trafik-dk
Available Tools
Weather Tools
get_weather_station
Get current weather data for a specific station by name.
Parameter | Type | Required | Description |
| string | Yes | Station name (e.g., "Kiruna", "Stockholm") |
Returns: Air/road temperatures, humidity, visibility, wind, precipitation, road conditions.
list_weather_stations
List available weather stations with optional filtering.
Parameter | Type | Required | Default | Description |
| string | No | - | Substring filter (case-insensitive) |
| number | No | 100 | Maximum stations to return (1-1000) |
get_weather_stations_near_location
Find weather stations near geographic coordinates.
Parameter | Type | Required | Default | Description |
| number | Yes | - | WGS84 latitude (-90 to 90) |
| number | Yes | - | WGS84 longitude (-180 to 180) |
| number | No | 30 | Search radius in kilometers |
| number | No | 50 | Maximum stations to return |
get_weather_observations
Get historical weather observations for trend analysis.
Parameter | Type | Required | Default | Description |
| number | Yes | - | Measurement point ID |
| number | No | 10 | Maximum observations (1-100) |
Camera Tools
get_cameras
Get traffic cameras with optional filtering.
Parameter | Type | Required | Default | Description |
| string | No | - | Substring filter (e.g., "E4") |
| number | No | - | Swedish county code (1-25) |
| number | No | 10 | Maximum cameras (1-100) |
Returns: Camera locations, GPS coordinates, bearings, photo URLs.
get_cameras_near_location
Find cameras near geographic coordinates.
Parameter | Type | Required | Default | Description |
| number | Yes | - | WGS84 latitude |
| number | Yes | - | WGS84 longitude |
| number | No | 30 | Search radius in kilometers |
| number | No | - | County filter for efficiency |
| number | No | 50 | Maximum cameras (1-1000) |
get_camera_image
Fetch the actual image from a traffic camera.
Parameter | Type | Required | Description |
| string | Yes | Photo URL from |
Returns: Base64-encoded camera image.
Traffic Tools
get_traffic_situations
Get current traffic incidents, accidents, roadwork, and closures.
Parameter | Type | Required | Default | Description |
| string | No | - | Road filter (e.g., "E4", "väg 862") |
| number | No | - | County code (1-25) |
| number | No | 50 | Maximum situations |
Supports SQL-style wildcards: E% matches E4, E20, etc.
get_traffic_flow
Get real-time traffic density and speed data.
Parameter | Type | Required | Default | Description |
| number | No | - | County code (1-25) |
| number | No | - | Trafikverket region (1-6) |
| string | No | - | Filter: "good", "degraded", "bad" |
| number | No | 50 | Maximum measurements |
get_road_conditions
Get road surface conditions including ice, snow, and water.
Parameter | Type | Required | Default | Description |
| string | No | - | Road filter (e.g., "E4") |
| number | No | 50 | Maximum conditions |
Swedish County Reference
Code | County | Code | County |
1 | Stockholm | 14 | Västra Götaland |
3 | Uppsala | 17 | Värmland |
4 | Södermanland | 18 | Örebro |
5 | Östergötland | 19 | Västmanland |
6 | Jönköping | 20 | Dalarna |
7 | Kronoberg | 21 | Gävleborg |
8 | Kalmar | 22 | Västernorrland |
9 | Gotland | 23 | Jämtland |
10 | Blekinge | 24 | Västerbotten |
12 | Skåne | 25 | Norrbotten |
13 | Halland |
Installation
Prerequisites
Node.js 18+
Trafikverket API key (free from api.trafikinfo.trafikverket.se)
Setup
# Clone the repository
git clone https://github.com/hniska/trafikverket-mcp.git
cd trafikverket-mcp
# Install dependencies
npm install
# Build
npm run buildConfiguration
Claude Desktop / Claude Code
Add to your MCP configuration (use absolute paths):
Production (compiled JavaScript):
{
"mcpServers": {
"trafikverket": {
"command": "node",
"args": ["/path/to/trafikverket-mcp/dist/index.js"],
"env": {
"TRAFIKVERKET_API_KEY": "YOUR_API_KEY"
}
}
}
}Development (TypeScript):
{
"mcpServers": {
"trafikverket": {
"command": "npx",
"args": ["tsx", "/path/to/trafikverket-mcp/src/index.ts"],
"env": {
"TRAFIKVERKET_API_KEY": "YOUR_API_KEY"
}
}
}
}Restart Claude after updating configuration.
Usage Examples
# Weather queries
"What's the current weather at Kiruna?"
"List weather stations near Stockholm"
"Find weather stations within 50km of Gothenburg"
# Camera queries
"Show traffic cameras on E4"
"Get cameras near Skellefteå"
"Fetch the image from camera X"
# Traffic queries
"Any traffic incidents on E4?"
"Check road conditions in Norrbotten"
"What's the traffic flow like in Stockholm county?"Development
Scripts
Command | Description |
| Run with tsx (development) |
| Compile TypeScript |
| Run compiled server |
| Run unit tests |
| Run E2E tests against real API |
| Lint code |
| Format with Prettier |
Project Structure
trafikverket-mcp/
├── src/
│ ├── index.ts # Entry point (STDIO transport)
│ ├── server.ts # MCP server (tool handlers)
│ ├── lib/
│ │ ├── trafikverket-client.ts # API client with caching
│ │ ├── xml-builder.ts # XML query construction
│ │ ├── xml-parser.ts # Response parsing
│ │ └── county-mapping.ts # County code lookup
│ └── types/
│ └── trafikverket.ts # TypeScript interfaces
├── design/
│ └── schemas/ # Official Trafikverket XML schemas
└── dist/ # Compiled outputArchitecture
Claude (MCP Client)
↓ JSON-RPC over STDIO
MCP Server
↓ XML Request
Trafikverket API
↓ XML Response
Parser → TypeScript Types
↓ Formatted Response
ClaudeError Handling
Invalid API key: Clear message with registration link
Network errors: Timeout (10s) and connection failures
API errors: Trafikverket error messages forwarded
Validation errors: Zod schema validation with details
Not found: Graceful handling for missing stations/cameras
Resources
License
MIT
Available Tools
10 toolsget_camera_imageFetch Camera ImageA
Fetch the actual image from a traffic camera. Takes a photo URL (obtained from get_cameras tool) and returns the image as base64-encoded data. Use this to retrieve the current traffic camera photo for viewing.
Inputs: photoUrl (required).
get_camerasGet Traffic CamerasA
Get information about traffic cameras in Sweden with photo URLs. Returns camera details including photo URLs, location, direction, county, and GPS coordinates. Use the photo URLs to fetch current camera images. Can be filtered by camera name pattern or by Swedish county number.
Inputs: limit, county, namePattern.
get_cameras_near_locationFind Nearby CamerasA
Find traffic cameras near a specific geographic location. Returns cameras within the specified radius, sorted by distance. Coordinates must be in WGS84 format (latitude, longitude). Example: cameras near Skellefteå (latitude: 64.75, longitude: 20.95)
Inputs: latitude (required), longitude (required), limit, county, +1 more.
get_road_conditionsGet Road ConditionsB
Get current road condition status including ice, snow, and water on road surfaces. Returns location-specific information about road surface conditions and temperatures. Can be filtered by road number.
Inputs: limit, roadNumber.
get_traffic_flowGet Traffic FlowB
Get real-time traffic flow data including vehicle counts and average speeds at measurement points. Returns current traffic density and speed information from monitoring sites across Sweden.
Inputs: limit.
get_traffic_situationsGet Traffic IncidentsA
Get current traffic situations including accidents, roadwork, closures, and incidents in Sweden. Returns active traffic disturbances with severity levels, locations, and time information. Can be filtered by road number or county.
Inputs: limit, county, roadNumber.
get_weather_observationsGet Weather HistoryB
Get historical weather observations for a specific measurement point. Returns time-series data of past weather conditions. Useful for analyzing weather trends.
Inputs: measurepointId (required), limit.
get_weather_stationGet Weather StationA
Get current weather data for a specific Swedish weather station by name. Returns temperature, humidity, wind, precipitation, and road conditions. Use this to check current road weather conditions in Sweden.
Inputs: stationName (required).
get_weather_stations_near_locationFind Nearby Weather StationsA
Find weather measurement stations near a specific geographic location. Returns stations within the specified radius, sorted by distance. Coordinates must be in WGS84 format (latitude, longitude). Example: weather stations near Skellefteå (latitude: 64.75, longitude: 20.95)
Inputs: latitude (required), longitude (required), limit, radiusKm.
list_weather_stationsList Weather StationsA
List available Swedish weather stations with optional name filtering. Use this to discover station names before querying specific weather data. Search uses case-insensitive substring matching (e.g., 'Timrå', 'Fjärryta', 'Uppsala', '222', 'Lidingöbron').
Inputs: limit, namePattern.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Most tools target distinct resources and actions, such as cameras, weather stations, traffic situations, traffic flow, and road conditions. However, get_weather_station, list_weather_stations, get_weather_stations_near_location, and get_weather_observations have some overlap in weather-station-related retrieval, and get_road_conditions partially overlaps with weather station road condition data. Descriptions help clarify, but an agent could still hesitate between current station weather and historical observations.
The set is almost entirely consistent snake_case with a get_ prefix (e.g., get_weather_station, get_cameras, get_traffic_flow), which is predictable. The one deviation is list_weather_stations, which uses a different verb but is still conventional and readable. Overall the naming is coherent with a minor stylistic variation.
Ten tools is a well-scoped size for a domain-specific Swedish traffic and weather data server. Each tool covers a distinct data type or access pattern, and there is no evident bloat or missing essential operation within the count itself.
The surface covers cameras (list, near-location, image), weather stations (list, specific, near-location, historical observations), traffic situations, traffic flow, and road conditions. This is broad and lifecycle-appropriate for the apparent domain. Minor gaps may exist, such as no direct near-location query for traffic situations, but agents can likely work around that with existing filters.
Maintenance
Related MCP Connectors
European NAP road data (DATEX II): incidents, roadworks, cameras, truck parking. Paid API key.
Swedish public data as read-only tools: registries, statistics, domains, transport, energy.
US & Canada 511 road data: incidents, closures, cameras, truck restrictions. Paid API key.
Stockholm transit: realtime departures, trip planning, disruptions and personal commute status.
Related MCP Servers
- AlicenseAqualityDmaintenanceQuery Swedish public data from AI tools. Includes company data, SCB statistics, weather, transport, public agencies, and more through the Apiverket API.253 npm2MIT
- AlicenseAqualityCmaintenanceProvides access to real-time Danish road traffic events, roadworks, and queues via public data from Vejdirektoratet, enabling AI assistants to check road conditions without any API keys.3MIT
- AlicenseAqualityBmaintenanceEnables querying Norwegian traffic messages (roadworks, closures, detours) from Statens vegvesen, filtered by route and time window. Supports both current and future travel times, with tools for route-based and general searches.3MIT
- FlicenseNot gradedqualityBmaintenanceEnables LLMs to access open real-time data from the Norwegian Public Roads Administration via DATEX II, including weather measurements and forecasts, webcams, travel times, and traffic messages.-