This MCP server provides access to Transport NSW's API services through a standardized Model Context Protocol interface. It allows you to search for transport stops, get information about service alerts, and monitor real-time departures from transport stops across New South Wales.
To get started with the Transport NSW MCP server:
uv venv
uv sync
.env
file in the project root with your API key:OPEN_TRANSPORT_API_KEY=your_api_key_here
uv run mcp dev api.py
Then visit http://localhost:5173 (or the port shown in your terminal) to access the inspector interface.
The server provides three main API functions: finding transport stops, getting alerts, and monitoring departures.
You can search for stops by name or location coordinates:
from api import find_transport_stops
# Search by name
stops = find_transport_stops(stop_name="Central Station")
# Search by coordinates with a radius in meters
central_station = '151.206290:-33.884080:EPSG:4326'
stops = find_transport_stops(coord=central_station, radius=500)
Retrieve information about service disruptions and 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)
Get real-time departure information for specific stops:
from api import get_departure_monitor
# Get all departures from Central Station
departures = get_departure_monitor("200060") # Central Station ID
# Get departures for a specific time
time_departures = get_departure_monitor("200060", time="15:30")
# Get only train departures
train_departures = get_departure_monitor("200060", mot_type=1) # 1 = Train
A comprehensive demo script is included to showcase 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
To verify your installation is working correctly, run the test suite:
uv run pytest
For coverage reporting:
uv run pytest --cov=api
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "transportnsw-mcp" '{"command":"uv","args":["run","mcp","dev","api.py"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"transportnsw-mcp": {
"command": "uv",
"args": [
"run",
"mcp",
"dev",
"api.py"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"transportnsw-mcp": {
"command": "uv",
"args": [
"run",
"mcp",
"dev",
"api.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect