find_buses_to_destination
Search for KMB and Long Win bus routes that travel to a specific destination in Hong Kong, such as Central, Mong Kok, or Airport.
Instructions
Find bus routes that go to a specified destination.
Args:
destination: The destination to search for (e.g., "Central", "Mong Kok", "Airport")
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| destination | Yes |
Implementation Reference
- kmb_mcp.py:190-224 (handler)The primary handler function for the 'find_buses_to_destination' tool. Decorated with @mcp.tool() for automatic registration in the MCP server. Uses type hints and docstring for schema. Calls helper function to fetch routes and formats output.@mcp.tool() async def find_buses_to_destination(destination: str) -> str: """Find bus routes that go to a specified destination. Args: destination: The destination to search for (e.g., "Central", "Mong Kok", "Airport") """ matching_routes = await find_routes_by_destination(destination) if not matching_routes: return f"Could not find any routes going to '{destination}'" # Group routes by origin for better readability routes_by_origin = {} for route in matching_routes: origin = route.get("orig_en", "Unknown") if origin not in routes_by_origin: routes_by_origin[origin] = [] routes_by_origin[origin].append({ "route": route["route"], "destination": route.get("dest_en", "Unknown"), "bound": "Inbound" if route["bound"] == "I" else "Outbound" }) # Format the results results = [f"Bus routes going to '{destination}':"] for origin, routes in routes_by_origin.items(): results.append(f"\nFrom {origin}:") for route_info in routes: results.append(f"- Route {route_info['route']} to {route_info['destination']} ({route_info['bound']})") return "\n".join(results)