Skip to main content
Glama

find_buses_to_destination

Search for KMB and Long Win bus routes to a specific destination in Hong Kong. Input the destination name to retrieve relevant bus route information efficiently.

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
NameRequiredDescriptionDefault
destinationYes

Implementation Reference

  • The main handler function for the 'find_buses_to_destination' tool, decorated with @mcp.tool() for registration. It calls the helper to find matching routes and formats the output grouped by origin.
    @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)
  • Core helper function implementing the logic to find routes by searching destination names (English and Chinese) in the full route list.
    async def find_routes_by_destination( destination: str, *, get_route_list_func: Callable[[], Awaitable[List]], ) -> List: routes = await get_route_list_func() matching_routes: List[Dict[str, Any]] = [] for route in routes: if ( destination.lower() in route["dest_en"].lower() or ( route.get("dest_tc") and destination.lower() in route["dest_tc"].lower() ) ): matching_routes.append(route) return matching_routes
  • Wrapper helper in the main file that delegates to the shared utils implementation with local get_route_list function.
    async def find_routes_by_destination(destination: str) -> List: """Delegate to shared implementation; keep signature for tests.""" return await handle_utils.find_routes_by_destination( destination, get_route_list_func=get_route_list, )

Other Tools

Related Tools

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/kennyckk/mcp_hkbus'

If you have feedback or need assistance with the MCP directory API, please join our Discord server