References swagger-client as a local dependency for integration with the Transport NSW API, enabling structured API access.
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: TfNSW Realtime Alerts 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
Get Transport Alerts
Monitor Real-time Departures
Demo Script
The project includes a comprehensive demo script that showcases all API functionality:
Testing
Local Testing
Run the complete test suite with pytest:
Run with coverage reporting:
Continuous 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 dependenciesuv.lock: Locks dependency versions for reproducible environments