Auckland Transport MCP Server
Enables searching for Auckland public transport stops and retrieving real-time transit schedules and timetables using the Auckland Transport API with GTFS standardized data.
README
Auckland Transport MCP Server
A Model Context Protocol (MCP) server for connecting to the Auckland Transport API. This server provides tools to search for public transport stops and retrieve transit information using the General Transit Feed Specification (GTFS) format.

Features
- Stop Search: Search for Auckland Transport stops by name (case-insensitive substring match)
- Stop Trip Information: Retrieve scheduled trips and timetables for specific stops
- GTFS Integration: Uses General Transit Feed Specification for standardized transit data exchange
- FastMCP Framework: Built on FastMCP for easy MCP server development
- Type Safety: Full type hints and Pydantic models for data validation
Prerequisites
- Python >= 3.11
- uv package manager (recommended) or pip
- Auckland Transport API credentials
Installation
- Clone the repository:
git clone <repository-url>
cd auckland_transport
- Install dependencies using uv:
uv sync
Or using pip:
pip install -e .
Configuration
Create a .env file in the root directory with your Auckland Transport API credentials:
AT_BASE_URL=https://api.at.govt.nz/gtfs/v3
AT_API_KEY=your_api_key_here
Note: Make sure to add .env to your .gitignore file (already included) to keep your API keys secure.
Usage
Running the MCP Server
Start the MCP server:
python src/app.py
Testing
Run the test script to verify the connection:
python src/test.py
Using the Tools
The server provides the following MCP tools:
search_stop(name: str) -> StopResponse
Searches for Auckland Transport stops by name (case-insensitive substring match).
Parameters:
name(str): The stop name to search for
Returns:
StopResponse: A Pydantic model containing a list of matching stops with attributes including:stop_id: Unique identifier for the stopstop_code: Public-facing stop codestop_name: Name of the stopstop_lat: Latitude coordinatestop_lon: Longitude coordinatelocation_type: Type of location (0=stop, 1=station, etc.)wheelchair_boarding: Wheelchair accessibility information (0=unknown, 1=accessible, 2=not accessible)
Example:
from at_service import ATService
at_service = ATService()
result = at_service.search_stop("University")
print(result.model_dump_json())
get_stop_trips_by_stop_id(stop_id: str) -> StopTripResponse
Retrieves scheduled trips for a specific stop on the current date and hour.
Parameters:
stop_id(str): The unique identifier of the stop
Returns:
StopTripResponse: A Pydantic model containing a list of stop trips with attributes including:arrival_time: Scheduled arrival time (HH:MM:SS format)departure_time: Scheduled departure time (HH:MM:SS format)route_id: Identifier for the routetrip_headsign: Text displayed on the vehicle for this tripstop_headsign: Text displayed on signage at the stopstop_sequence: Order of this stop in the trip sequencedirection_id: Direction of travel (0 or 1)service_date: Date of service (YYYY-MM-DD format)shape_id: Identifier for the shape/geometry of the routepickup_type: Pickup type (0=regular, 1=none, 2=phone, 3=driver)drop_off_type: Drop-off type (0=regular, 1=none, 2=phone, 3=driver)
Example:
from at_service import ATService
at_service = ATService()
# First, search for a stop to get its stop_id
stops = at_service.search_stop("University")
if stops.data:
stop_id = stops.data[0].attributes.stop_id
trips = at_service.get_stop_trips_by_stop_id(stop_id)
print(trips.model_dump_json())
Project Structure
auckland-transport/
├── src/
│ ├── app.py # FastMCP server application with MCP tools
│ ├── at_service.py # Auckland Transport API service class
│ ├── gtfs_types.py # Pydantic models for GTFS data structures
│ ├── test.py # Test script for API connectivity
│ └── utils.py # Utility functions
├── .env # Environment variables (not in repo, create locally)
├── pyproject.toml # Project dependencies and metadata
├── uv.lock # Dependency lock file
└── README.md # This file
Dependencies
fastmcp>=2.13.2: FastMCP framework for building MCP serversdotenv>=0.9.9: Environment variable managementpydantic: Data validation and modeling for GTFS structuresrequests: HTTP library for API calls
Note: The project uses uv for dependency management. All dependencies are specified in pyproject.toml.
Development
Adding New Tools
To add new MCP tools, edit src/app.py and add new tool functions decorated with @mcp.tool:
@mcp.tool
def your_new_tool(param: str) -> ReturnType:
# Your implementation
return result
API Reference
The Auckland Transport API uses GTFS (General Transit Feed Specification) for data exchange. For more information about the API, visit the Auckland Transport API documentation.
Data Models
The project uses Pydantic models defined in gtfs_types.py to validate and structure API responses:
- StopAttributes: Contains stop location and accessibility information
- Stop: Represents a single stop resource with type, ID, and attributes
- StopResponse: Container for multiple stop search results
- StopTripAttributes: Contains trip timing, route, and service information
- StopTrip: Represents a single stop trip resource
- StopTripResponse: Container for multiple stop trip results
All models follow the GTFS standard and are fully typed for better IDE support and error checking.
Troubleshooting
Common Issues
-
API Key Not Found: Ensure your
.envfile exists in the root directory and contains bothAT_BASE_URLandAT_API_KEY. -
Empty Results: The API returns data for the current date and hour. If searching for trips, ensure there are scheduled services at the current time.
-
Connection Errors: Verify your internet connection and that the Auckland Transport API is accessible from your network.
References
- GTFS Static Overview - Google Developers - Official Google documentation for GTFS (General Transit Feed Specification)
- GTFS Documentation - gtfs.org - Official GTFS specification documentation maintained by MobilityData
License
MIT License
Copyright (c) 2025 Aira Technologies Limited
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。