Skip to main content
Glama

vehicle_positions_tool

Retrieve real-time vehicle positions for a specific bus route, providing ID, coordinates, bearing, and speed data for tracking current locations.

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

  • Handler function for vehicle_positions_tool, registered via @mcp.tool decorator. Ensures data initialization and calls the vehicle_positions helper.
    @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 that filters vehicle positions from realtime data by route_id and returns formatted list of positions.
    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