Stockholm Traffic Planner MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Stockholm Traffic Planner MCP Server
This MCP server is meant as an example of how to implement a simple Model Context Protocol (MCP) server in Python. Making use of Public Transport data from Stockholm, Sweden, this server allows AI assistants to plan journeys using the local public transport system.
Also, how nice is it not to ask for directions in the terminal using Claude Code.
Features
Stop Lookup: Find stops and stations by name with detailed information
Journey Planning: Plan routes between stops with multiple options
Real-time Information: Uses real-time departure/arrival data when available
Smart Filtering: Exclude walking routes, filter transport types, control walking distances
Stockholm Time: All times converted to local Stockholm timezone
Simplified Responses: Clean, structured data optimized for AI consumption
Related MCP server: mcp-tfl-journey
Tools Available
stop_lookup(name: str)
Search for stops and stations by name in Stockholm's public transport system.
Parameters:
name: Name of the stop/station to search for
Returns:
List of matching stops with IDs, names, coordinates, and match quality
plan_journey(origin_id, destination_id, ...)
Plan a journey between two stops with advanced filtering options.
Parameters:
origin_id: Origin stop ID (from stop_lookup)destination_id: Destination stop ID (from stop_lookup)trips: Number of alternative routes (default: 3)exclude_walking: Exclude walking-only routes (default: True)exclude_transport_types: List of transport types to exclude: ['bus', 'metro', 'train', 'tram', 'ship']departure_time: Departure time in HH:MM format (default: now)max_walking_distance: Maximum walking distance in meters (default: 500)
Returns:
Simplified journey information with times, transport types, and transfers
Installation
Prerequisites
Python 3.11+
uv (recommended) or pip
Using uv (Recommended)
# Clone the repository
git clone https://github.com/argia-andreas/stockholm-traffic-mcp.git
cd stockholm-traffic-mcp
# Install dependencies
uv sync
# Run the server with MCP inspector
uv run mcp dev server.pyUsing pip
# Clone the repository
git clone https://github.com/your-username/stockholm-traffic-mcp.git
cd stockholm-traffic-mcp
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run the server
python server.pyUsage Examples
To use the server, simply ask your AI assistant a question like:
"How do I get from Odenplan to Slussen?"
"When is the next metro from Odenplan to Slussen?"
Basic Journey Planning
# 1. Find origin stop
stops = stop_lookup("Odenplan")
origin_id = stops[0]["id"] # Get the best match
# 2. Find destination stop
stops = stop_lookup("Slussen")
destination_id = stops[0]["id"]
# 3. Plan journey
journey = plan_journey(origin_id, destination_id)Advanced Filtering
# Metro and bus only, departing at 2 PM
journey = plan_journey(
origin_id="9091001000009117",
destination_id="9091001000009192",
exclude_transport_types=["train", "tram", "ship"],
departure_time="14:00",
max_walking_distance=300
)Sample Response
{
"journeys": [
{
"duration_minutes": 23,
"interchanges": 1,
"legs": [
{
"origin": "Stockholm, Odenplan",
"destination": "Stockholm, T-Centralen",
"departure_time": "14:05",
"arrival_time": "14:12",
"transport_type": "Metro",
"line": "17",
"direction": "Skarpnäck"
},
{
"origin": "Stockholm, T-Centralen",
"destination": "Stockholm, Slussen",
"departure_time": "14:15",
"arrival_time": "14:18",
"transport_type": "Metro",
"line": "19",
"direction": "Hagsätra"
}
]
}
]
}MCP Client Configuration
Claude Desktop
Add to your Claude Desktop configuration:
{
"mcpServers": {
"stockholm-traffic": {
"command": "uv",
"args": ["run", "mcp", "dev", "server.py"],
"cwd": "/path/to/stockholm-traffic-mcp"
}
}
}Claude Code
Add to your Claude Code configuration:
claude mcp add traffic-planner -- uv run mcp run /path/to/stockholm-traffic-mcp/server.py Other MCP Clients
The server follows the standard MCP protocol and should work with any MCP-compatible client.
API Reference
This server uses the SL Journey Planner API from Trafiklab.
Data Sources
Stop Lookup:
/v2/stop-finderendpointJourney Planning:
/v2/tripsendpointReal-time Data: Integrated real-time departure/arrival information
Time Handling
All API responses are in UTC
Server automatically converts to Stockholm local time (Europe/Stockholm)
Handles daylight saving time transitions
Returns user-friendly HH:MM format
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
# Clone and setup
git clone https://github.com/argia-andreas/stockholm-traffic-mcp.git
cd stockholm-traffic-mcp
uv sync
# Run tests
uv run pytest
# Run linting
uv run ruff check
uv run black --check .License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Trafiklab for providing the Stockholm public transport API
SL (Storstockholms Lokaltrafik) for the underlying transport data
Model Context Protocol for the MCP specification
Support
Issues: Report bugs and request features on GitHub Issues
API Issues: For SL API problems, check Trafiklab documentation Trafiklab
Changelog
v1.0.0
Initial release
Stop lookup functionality
Journey planning with advanced filtering
Real-time data integration
Stockholm timezone conversion
Simplified response format
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Stockholm public transport (SL): live departures, trips to addresses with exits, disruptions.
Stockholm transit: realtime departures, trip planning, disruptions and personal commute status.
Stockholm archipelago boats: realtime departures, trip planning, disruptions, island guides.
Norwegian transport (Entur) and geodata (Kartverket): trips, departures, addresses, elevation.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to access real-time Transport for London data, including tube/bus arrivals, line status, journey planning, and disruptions.1-
- AlicenseBqualityDmaintenanceProvides real-time Transport for London journey data, including routes, alerts, and disruptions, allowing AI assistants to search journeys and get station information.112 npm4ISC
- AlicenseNot gradedqualityCmaintenanceProvides access to Norway's nationwide public transport data (all modes) via the Entur API, enabling queries about routes, stops, and departures through natural language.54 npmMIT
- AlicenseAqualityCmaintenanceEnables AI agents to search for stops and stations across all Norwegian public transport and to fetch real-time departure data — planned versus expected times, delays, platform, operator, and disruption messages — with no API key required. Covers bus, tram, metro, train, and ferry nationwide through Entur's open APIs, with filtering by line, destination, and future departure time.2MIT