"""MCP tool for listing all routes."""
from typing import Any
from ..ingest.static_loader import GTFSData
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 (use empty string for None)
routes.sort(key=lambda x: x.get("short_name") or "")
return routes