Skip to main content
Glama

trip_alerts_tool

Retrieve real-time service alerts for CATA bus routes, including route-specific notifications with headers, descriptions, and severity levels.

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

  • The MCP tool handler function for trip_alerts_tool. It ensures data initialization and delegates to the trip_alerts helper function.
    @mcp.tool async def trip_alerts_tool(route_id: Optional[str] = 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 helper function that processes realtime GTFS alerts, filters by route_id if specified, and formats them into the response structure.
    async def trip_alerts(realtime_data: RealtimeData, route_id: Optional[str] = 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