Skip to main content
Glama
kennyckk

KMB Bus MCP Server

get_all_routes_at_stop

Find all bus routes that serve a specific bus stop. Provide the stop name to see which routes pass through that location.

Instructions

Get all bus routes that pass through a specified bus stop.

Args:
    stop_name: Name of the bus stop

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stop_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @mcp.tool() decorated handler function implementing get_all_routes_at_stop, which finds stops by name, retrieves route-stop mappings, groups routes by stop, fetches route details, and formats the list of routes serving the stop.
    @mcp.tool()
    async def get_all_routes_at_stop(stop_name: str) -> str:
        """Get all bus routes that pass through a specified bus stop.
        
        Args:
            stop_name: Name of the bus stop
        """
        # Find stops matching the name
        stops = await find_stops_by_name(stop_name)
        
        if not stops:
            return f"Could not find any stops matching '{stop_name}'"
        
        results = []
        
        for stop in stops:
            stop_id = stop["stop"]
            stop_name_en = stop["name_en"]
            
            # Get all route-stop combinations
            route_stops = await get_route_stop_list()
            
            # Filter for this stop
            stop_routes = [rs for rs in route_stops if rs["stop"] == stop_id]
            
            if not stop_routes:
                results.append(f"No routes found for stop '{stop_name_en}' ({stop_id})")
                continue
            
            # Group by route for better readability
            routes_info = {}
            for rs in stop_routes:
                route = rs["route"]
                bound = rs["bound"]
                service_type = rs["service_type"]
                
                key = f"{route}:{service_type}"
                if key not in routes_info:
                    routes_info[key] = []
                routes_info[key].append(bound)
            
            # Format results
            stop_results = [f"Routes serving '{stop_name_en}' ({stop_id}):"]
            
            # Get full route information for each route
            for key, bounds in routes_info.items():
                route, service_type = key.split(":")
                route_data = await get_route_details(route)
                
                for r in route_data:
                    if r["service_type"] == service_type and r["bound"] in bounds:
                        origin = r.get("orig_en", "Unknown")
                        dest = r.get("dest_en", "Unknown")
                        direction = "→" if r["bound"] == "O" else "←"
                        
                        stop_results.append(f"- Route {route}: {origin} {direction} {dest}")
            
            results.append("\n".join(stop_results))
        
        return "\n\n".join(results)
  • kmb_mcp.py:311-311 (registration)
    Registration of the get_all_routes_at_stop tool via @mcp.tool() decorator.
    @mcp.tool()
  • Type hints and docstring defining input (stop_name: str) and output (str) schema for the tool.
    async def get_all_routes_at_stop(stop_name: str) -> str:
        """Get all bus routes that pass through a specified bus stop.
        
        Args:
            stop_name: Name of the bus stop
        """
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It states what the tool does but doesn't describe response format, error handling, rate limits, or whether it requires authentication. For a read operation with no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences: one stating the purpose and another documenting the parameter. It's front-loaded with the core functionality, though the parameter documentation could be integrated more seamlessly rather than as a separate 'Args' section.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one parameter) and the presence of an output schema (which handles return values), the description is minimally adequate. However, with no annotations and incomplete behavioral transparency, it doesn't fully prepare an agent for edge cases or system constraints, leaving room for improvement in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for the single parameter 'stop_name' by explaining it's 'Name of the bus stop', which clarifies its purpose beyond the schema's basic title. With 0% schema description coverage and only one parameter, this adequately compensates, though it doesn't detail format constraints (e.g., case sensitivity).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get all bus routes') and resource ('that pass through a specified bus stop'), making the purpose immediately understandable. It distinguishes from sibling tools like 'find_stop_by_name' (which finds stops) and 'get_next_bus' (which provides timing information) by focusing on route enumeration at a stop.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'find_buses_to_destination' or 'get_route_stops_info'. It lacks context about prerequisites (e.g., whether the stop must exist in the system) or exclusions (e.g., not for real-time bus tracking).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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