list_routes_tool
Retrieve all available bus routes with IDs, names, and colors for the Centre Area Transportation Authority (CATA) system.
Instructions
List all available bus routes.
Returns a list of routes with their ID, short name, long name, and color.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/catabus_mcp/server.py:83-92 (handler)The main handler function for the 'list_routes_tool' tool. It is decorated with @mcp.tool for registration and executes the tool logic by ensuring data initialization and calling the list_routes helper.@mcp.tool async def list_routes_tool() -> List[Dict[str, Any]]: """List all available bus routes. Returns a list of routes with their ID, short name, long name, and color. """ await ensure_initialized() if not gtfs_data or not gtfs_data.routes: return [] return await list_routes(gtfs_data)
- Helper function containing the core logic to extract, format, and sort route information from the GTFS data.async def list_routes(gtfs_data: GTFSData) -> List[Dict[str, Any]]: """ List all available bus routes. Returns: List of route information with id, short name, long name, and color. """ routes = [] for route_id, route in gtfs_data.routes.items(): routes.append({ "route_id": route.route_id, "short_name": route.route_short_name, "long_name": route.route_long_name, "color": f"#{route.route_color}" if route.route_color else None, }) # Sort by short name for consistency routes.sort(key=lambda x: x["short_name"]) return routes