Skip to main content
Glama
Pranav-Karra-3301

CATA Bus MCP Server

vehicle_positions_tool

Track live bus positions on specific routes to monitor real-time vehicle locations, coordinates, bearing, and speed for CATA transportation services.

Instructions

Get current positions of vehicles on a specific route.

Args: route_id: The route ID to filter by (e.g., "BL" for Blue Loop)

Returns: List of vehicle positions with ID, coordinates, bearing, and speed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
route_idYes

Implementation Reference

  • MCP tool handler and registration for vehicle_positions_tool. Includes input schema via type hints and docstring, ensures data initialization, and calls the core vehicle_positions helper function.
    @mcp.tool
    async def vehicle_positions_tool(route_id: str) -> list[dict[str, Any]]:
        """Get current positions of vehicles on a specific route.
    
        Args:
            route_id: The route ID to filter by (e.g., "BL" for Blue Loop)
    
        Returns:
            List of vehicle positions with ID, coordinates, bearing, and speed
        """
        await ensure_initialized()
        return await vehicle_positions(realtime_poller.data, route_id)
  • Core helper function implementing the vehicle positions logic: filters realtime vehicle data by route_id and formats output with vehicle_id, lat, lon, bearing, and speed.
    async def vehicle_positions(realtime_data: RealtimeData, route_id: str) -> list[dict[str, Any]]:
        """
        Get current positions of vehicles on a specific route.
    
        Args:
            realtime_data: The GTFS realtime data.
            route_id: The route ID to filter by.
    
        Returns:
            List of vehicle positions with ID, coordinates, bearing, and speed.
        """
        vehicles = []
    
        for vehicle_id, position in realtime_data.vehicle_positions.items():
            # Filter by route if specified
            if position.route_id == route_id:
                vehicles.append(
                    {
                        "vehicle_id": vehicle_id,
                        "lat": position.latitude,
                        "lon": position.longitude,
                        "bearing": position.bearing,
                        "speed_mps": position.speed,
                    }
                )
    
        return vehicles

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