Transport NSW API
STDIOMCP service for interacting with Transport NSW API using direct HTTP requests.
MCP service for interacting with Transport NSW API using direct HTTP requests.
A Claude MCP for interacting with the Transport NSW API using direct HTTP requests.
This project implements a Model Context Protocol (MCP) service for Transport NSW's API.
uv venv uv sync
.env
file with your API key:
OPEN_TRANSPORT_API_KEY=your_api_key_here
And visit the server at http://localhost:5173 (port might be different).uv run mcp dev api.py
MCP Examples coming soon. Standard Python examples below:
from api import find_transport_stops # Search by name stops = find_transport_stops(stop_name="Central Station") # Search by coordinates (Central Station area) central_station = '151.206290:-33.884080:EPSG:4326' stops = find_transport_stops(coord=central_station, radius=500)
from api import get_transport_alerts # Get all current alerts alerts = get_transport_alerts() # Get alerts for a specific date date_alerts = get_transport_alerts(date='22-03-2025') # Get train alerts only (mot_type=1) train_alerts = get_transport_alerts(mot_type=1)
from api import get_departure_monitor # Get departures from Central Station departures = get_departure_monitor("200060") # Central Station ID # Get departures for a specific time from datetime import datetime time_departures = get_departure_monitor("200060", time="15:30") # Get only train departures train_departures = get_departure_monitor("200060", mot_type=1) # 1 = Train
The project includes a comprehensive demo script that showcases all API functionality:
# Run the full demo python demo.py # Run specific sections python demo.py --stops # Stop finder demo python demo.py --alerts # Transport alerts demo python demo.py --departures # Departure monitoring demo
Run the complete test suite with pytest:
uv run pytest
Run with coverage reporting:
uv run pytest --cov=api
Tests automatically run on GitHub Actions for every push and pull request to the main branch. The workflow:
To use this feature:
OPEN_TRANSPORT_API_KEY
as a GitHub repository secretThis project follows the Model Context Protocol specification, allowing AI models to access Transport NSW data through a standardized interface.
This project uses uv, a modern Python package manager written in Rust. Dependencies are managed through:
pyproject.toml
: Defines project dependenciesThis project is licensed under the MIT License.