Leopaexd/stockholm-public-transport-mcp
If you are the rightful owner of stockholm-public-transport-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The SL Transit MCP Server provides journey planning and real-time transit information for Stockholm Local Transit (SL), facilitating daily commute monitoring and planning.
SL Transit MCP Server
A Model Context Protocol (MCP) server providing Stockholm Local Transit (SL) journey planning and real-time information for daily commute monitoring and journey planning.
Features
- Coordinate-based operations: Find stops and plan journeys using latitude/longitude coordinates
- Real-time departures: Get upcoming departures from nearby stops
- Journey planning: Calculate routes between any two points
- Traffic monitoring: Check for current disruptions and service alerts
- Saved routes: Monitor pre-configured commute routes
- Committee integration: Designed for AI agent workflows
Installation
- Install dependencies:
pip install -e .
- Configure saved routes (optional):
Copy
sl_transit_config.jsonand customize with your locations.
API Access
No API keys required! The SL APIs are free to use without authentication. Simply install and run the server.
Usage
MCP Tools
find_nearby_stops
Find all transit stops within a radius of given coordinates.
await find_nearby_stops(
lat=59.3293,
lon=18.0686,
radius_meters=500,
transport_modes=["metro", "bus"]
)
get_departures_near_location
Get upcoming departures from all stops near coordinates.
await get_departures_near_location(
lat=59.3293,
lon=18.0686,
radius_meters=300,
transport_mode="metro",
time_window_minutes=30
)
plan_journey_by_coordinates
Plan a journey between two coordinate points.
await plan_journey_by_coordinates(
origin_lat=59.3293,
origin_lon=18.0686,
dest_lat=59.3326,
dest_lon=18.0649,
departure_time="2024-01-15T08:30:00",
transport_modes=["metro", "bus"]
)
get_deviations
Get current traffic disruptions and service alerts.
await get_deviations(
transport_modes=["metro"],
lines=["Red line"],
severity="high"
)
check_saved_route
Check status of a pre-configured route.
await check_saved_route("home_to_work")
Configuration
The server loads configuration from sl_transit_config.json:
{
"saved_routes": {
"home_to_work": {
"name": "Home to Work",
"origin": {
"lat": 59.3293,
"lon": 18.0686,
"label": "Home"
},
"destination": {
"lat": 59.3326,
"lon": 18.0649,
"label": "Office"
},
"typical_duration_minutes": 35,
"notify_if_delay_exceeds_minutes": 5,
"preferred_transport_modes": ["metro", "bus"]
}
},
"favorite_locations": {
"home": {
"lat": 59.3293,
"lon": 18.0686,
"label": "Home"
}
}
}
Committee Integration
This server is designed to work with AI planning agents (the "Oliver Care Committee"):
Morning Planning
# Check commute before daily planning
commute_status = await check_saved_route("home_to_work")
if "delay" in commute_status:
# Add note to daily plan
# Suggest earlier departure
Afternoon Reminders
# Help Oliver leave on time
work_to_home = await check_saved_route("work_to_home")
# Calculate when to leave
# Provide ADHD-friendly reminder
Meeting Planning
# Calculate travel time for external meetings
journey = await plan_journey_by_coordinates(
origin_lat=office_lat,
origin_lon=office_lon,
dest_lat=meeting_lat,
dest_lon=meeting_lon
)
# Add buffer time for delays
# Include in meeting notes
Development
Run the server:
python server.py
Run tests:
pytest
Format code:
black server.py
ruff check server.py
Quick Start
Since no API keys are required, you can start using the server immediately:
- Install:
pip install -e . - Run:
python server.py - Test with coordinates: Use any Stockholm area coordinates to find nearby stops
Logging
Logs are written to logs/sl_transit_mcp.log with weekly rotation and monthly retention.
License
MIT License - see LICENSE file for details.