Skip to main content
Glama
Pranav-Karra-3301

CATA Bus MCP Server

list_routes_tool

Retrieve all available bus routes with their ID, name, and color information from the CATA Bus 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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for list_routes_tool, decorated with @mcp.tool for registration and execution. Ensures data initialization and delegates to 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)
  • Core helper function that extracts and formats route data from GTFSData, including sorting by short name.
    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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Pranav-Karra-3301/catabus-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server