Skip to main content
Glama
Pranav-Karra-3301

CATA Bus MCP Server

trip_alerts_tool

Retrieve real-time service alerts for CATA bus routes to stay informed about delays, detours, and schedule changes.

Instructions

Get current service alerts.

Args: route_id: Optional route ID to filter alerts (if None, returns all)

Returns: List of alerts with route ID, header, description, and severity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
route_idNo

Implementation Reference

  • Primary handler function for the 'trip_alerts_tool' MCP tool. Registered via @mcp.tool decorator. Ensures GTFS data initialization and calls the helper function to retrieve filtered alerts.
    @mcp.tool
    async def trip_alerts_tool(route_id: str | None = None) -> list[dict[str, Any]]:
        """Get current service alerts.
    
        Args:
            route_id: Optional route ID to filter alerts (if None, returns all)
    
        Returns:
            List of alerts with route ID, header, description, and severity
        """
        await ensure_initialized()
        return await trip_alerts(realtime_poller.data, route_id)
  • Core implementation logic for extracting, filtering (by route_id), and formatting service alerts from GTFS realtime data's alerts list.
    async def trip_alerts(
        realtime_data: RealtimeData, route_id: str | None = None
    ) -> list[dict[str, Any]]:
        """
        Get current service alerts.
    
        Args:
            realtime_data: The GTFS realtime data.
            route_id: Optional route ID to filter alerts (if None, returns all).
    
        Returns:
            List of alerts with route ID, header, description, and severity.
        """
        alerts = []
    
        for alert in realtime_data.alerts:
            # Check if this alert is relevant to the requested route
            if route_id:
                relevant = False
                for entity in alert.informed_entities:
                    if entity.get("route_id") == route_id:
                        relevant = True
                        break
                if not relevant:
                    continue
    
            # Get affected route IDs
            affected_routes = []
            for entity in alert.informed_entities:
                if "route_id" in entity:
                    affected_routes.append(entity["route_id"])
    
            alerts.append(
                {
                    "route_id": affected_routes[0] if len(affected_routes) == 1 else None,
                    "affected_routes": affected_routes,
                    "header": alert.header,
                    "description": alert.description,
                    "severity": alert.severity,
                }
            )
    
        return alerts

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