Transport NSW API Client MCP
References swagger-client as a local dependency for integration with the Transport NSW API, enabling structured API access.
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., "@Transport NSW API Client MCP find transport stops near Central Station"
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.
Transport NSW API Client (MCP Implementation)
A Claude MCP for interacting with the Transport NSW API using direct HTTP requests.
About
This project implements a Model Context Protocol (MCP) service for Transport NSW's API.
Related MCP server: transport12 MCP Server
Setup
Clone this repository
Install dependencies using uv (fast Python package manager):
uv venv uv syncCreate a
.envfile with your API key:OPEN_TRANSPORT_API_KEY=your_api_key_here(Optional) Run the MCP Inspector:
uv run mcp dev api.pyAnd visit the server at http://localhost:5173 (port might be different).
Features
Stop Finder API: Find transport stops by name or coordinates
Alerts API: Get information about transport alerts and disruptions
Departure Monitor API: Get real-time departure information for transport stops
MCP Implementation: Structured as a Model Context Protocol service
Usage Examples
MCP Examples coming soon. Standard Python examples below:
Find Transport Stops
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)Get Transport Alerts
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)Monitor Real-time Departures
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 = TrainDemo Script
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 demoTesting
Local Testing
Run the complete test suite with pytest:
uv run pytestRun with coverage reporting:
uv run pytest --cov=apiContinuous Integration
Tests automatically run on GitHub Actions for every push and pull request to the main branch. The workflow:
Sets up Python 3.10
Installs uv and project dependencies
Runs tests with coverage reporting
To use this feature:
Add your
OPEN_TRANSPORT_API_KEYas a GitHub repository secretPush your code to GitHub
MCP Integration
This project follows the Model Context Protocol specification, allowing AI models to access Transport NSW data through a standardized interface.
Package Management
This project uses uv, a modern Python package manager written in Rust. Dependencies are managed through:
pyproject.toml: Defines project dependencies
License
This project is licensed under the MIT License.
Available Tools
3 toolsfind_transport_stopsB
Find transport stops around a specific location.
Args:
location_coord (str): Coordinates in format 'LONGITUDE:LATITUDE:EPSG:4326'
stop_type (str): Type of stops to find: 'BUS_POINT', 'POI_POINT', or 'GIS_POINT'
radius (int): Search radius in meters
Returns:
API response with transport stops
Inputs: location_coord (required), stop_type, radius.
get_departure_monitorA
Get real-time departure monitor information for a specific stop from the Trip Planner API.
This function uses direct HTTP requests to the Transport NSW API.
Args:
stop_id (str): Stop ID or global stop ID
date (str, optional): Date in DD-MM-YYYY format. Defaults to today's date.
time (str, optional): Time in HH:MM format. Defaults to current time.
mot_type (int, optional): Mode of transport type filter. Options:
1: Train
2: Metro
4: Light Rail
5: Bus
7: Coach
9: Ferry
11: School Bus
max_results (int, optional): Maximum number of results to return. Default is 1.
Returns:
list: Simplified list of departure information
Inputs: stop_id (required), date, time, mot_type, +1 more.
get_transport_alertsB
Get transport alerts from the Transport NSW API.
Args:
date (str, optional): Date in DD-MM-YYYY format. Defaults to today's date.
mot_type (int, optional): Mode of transport type filter. Options:
1: Train
2: Metro
4: Light Rail
5: Bus
7: Coach
9: Ferry
11: School Bus
stop_id (str, optional): Stop ID or global stop ID to filter by.
line_number (str, optional): Line number to filter by (e.g., '020T1').
operator_id (str, optional): Operator ID to filter by.
Returns:
dict: API response containing alerts information
Inputs: date, mot_type, stop_id, line_number, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: find_transport_stops locates stops, get_departure_monitor provides real-time departures, and get_transport_alerts retrieves service alerts. There is no overlap in functionality, and the descriptions clearly differentiate their roles.
All tool names follow a consistent verb_noun pattern using snake_case: find_transport_stops, get_departure_monitor, and get_transport_alerts. The naming is predictable and readable throughout the set.
With only 3 tools, the set feels thin for a transport API client, lacking operations like route planning, trip details, or fare information. While the tools cover basic needs, the scope suggests more comprehensive coverage would be expected.
The tools provide core functionality for stops, departures, and alerts, but there are notable gaps. Missing operations include trip planning, route searches, service status beyond alerts, and fare queries, which are typical for a transport API and could limit agent effectiveness.
Maintenance
Related MCP Connectors
Transport for NSW MCP — journey planning, live departures, service alerts and commuter car-park…
Transport for London (TfL) Unified API MCP — keyless.
Swiss Transport MCP — wraps Transport Open Data API (free, no auth)
Provide real-time transportation data including bus arrivals, train service alerts, carpark availa…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server for interacting with the Berlin Public Transport (BVG) API to search for locations and plan journeys. It provides real-time access to departures, arrivals, trip details, and vehicle tracking within Berlin's transit network.MIT
- AlicenseBqualityDmaintenanceMCP server that integrates with the transport12 API to provide tools for searching stops, routes, arrivals, and vehicle forecasts, enabling natural language interaction with public transport data.1712 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables querying real-time BART and SF Muni transit data, including departures, trip planning, fares, advisories, routes, alerts, vehicle positions, and schedules, from any MCP-compatible client.1MIT
- AlicenseAqualityBmaintenanceEnables LLM clients to search stops, plan journeys, check live departures, service alerts, nearby locations, and vehicle positions using Transport for NSW open data, with per-request API key authentication.101MIT