Skip to main content
Glama

get_station_number

Retrieve station identification numbers by providing station names for Nagoya's bus system, enabling accurate transit data queries and route planning.

Instructions

Get station number for a given station name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
station_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main tool handler function that executes the logic to find a station number by name using exact match or fuzzy matching with difflib. It uses cached station names from the bus client.
    async def get_station_number(
        ctx: Context, station_name: str
    ) -> StationNumberResponse | None:
        """Get station number for a given station name."""
        client = ctx.request_context.lifespan_context.bus_client
    
        log.info("Getting station number for %s", station_name)
        station_names = await _get_station_names(client)
    
        # First try exact match
        station_number = station_names.get(station_name)
        if station_number is not None:
            return StationNumberResponse(
                success=True, station_name=station_name, station_number=station_number
            )
    
        # If no exact match, try fuzzy matching
        log.info("No exact match found for %s, trying fuzzy matching", station_name)
        closest_matches = difflib.get_close_matches(
            station_name, station_names.keys(), n=1, cutoff=0.6
        )
    
        if closest_matches:
            closest_station = closest_matches[0]
            closest_station_number = station_names[closest_station]
            log.info(
                "Found closest match: %s (station number: %s)",
                closest_station,
                closest_station_number,
            )
            return StationNumberResponse(
                success=True,
                station_name=closest_station,
                station_number=closest_station_number,
            )
    
        log.info("No fuzzy match found for %s", station_name)
        return StationNumberResponse(success=False)
  • Pydantic model defining the response schema for the get_station_number tool, including success flag and optional station details.
    class StationNumberResponse(BaseModel):
        success: bool
        station_name: str | None = None
        station_number: int | None = None
  • Registration of the get_station_number tool (and get_timetable) on the FastMCP server instance.
    mcp_server: FastMCP = FastMCP("Nagoya Bus MCP", version=version, lifespan=lifespan)
    mcp_server.tool(get_station_number)
    mcp_server.tool(get_timetable)
  • Helper function to fetch and cache station names by number from the client, used by get_station_number.
    async def _get_station_names(client: Client) -> dict[str, int]:
        global _cached_station_names  # noqa: PLW0603
        if _cached_station_names is None:
            _cached_station_names = (await client.get_station_names()).root
        return _cached_station_names
  • Helper function to fetch and cache station numbers by name (inverse of station names), shared with other tools.
    async def _get_station_numbers(client: Client) -> dict[int, str]:
        global _cached_station_numbers  # noqa: PLW0603
        if _cached_station_numbers is None:
            _cached_station_numbers = {
                num: name for name, num in (await _get_station_names(client)).items()
            }
        return _cached_station_numbers
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states the basic function without addressing key behavioral aspects such as whether this is a read-only operation (implied by 'Get' but not explicit), error handling (e.g., what happens if the station name isn't found), performance characteristics, or authentication requirements. This leaves significant gaps for an AI agent to understand 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.

Conciseness5/5

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

The description is extremely concise—a single sentence that directly states the tool's purpose without any unnecessary words. It's front-loaded with the core functionality, making it easy to parse quickly. Every word earns its place, and there's no redundancy or fluff.

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, it lacks context about behavioral traits (e.g., error cases, performance) and usage guidelines, which are important even for simple tools. The description covers the basic 'what' but misses the 'how' and 'when', 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.

Parameters3/5

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

The description adds minimal semantic context beyond the input schema. It clarifies that the 'station_name' parameter is used to retrieve a station number, which is helpful since schema description coverage is 0% (no schema descriptions provided). However, it doesn't elaborate on format expectations (e.g., case sensitivity, partial matches) or provide examples, so the value added is limited. With only one parameter and no schema descriptions, a baseline of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get station number for a given station name.' It specifies both the action ('Get') and the resource ('station number'), making it easy to understand what the tool does. However, it doesn't differentiate from its sibling tool 'get_timetable', which likely serves a different purpose (retrieving schedule information rather than mapping names to numbers).

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. It doesn't mention the sibling tool 'get_timetable' or explain scenarios where one would be preferred over the other (e.g., use this for identifier lookup, use 'get_timetable' for schedule information). There's also no information about prerequisites or constraints for usage.

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/ymyzk/nagoya-bus-mcp'

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