Skip to main content
Glama

ch_search_stations

Search for Swiss train stations by name or location using public transport data. Find station information to plan travel routes across Switzerland.

Instructions

Search for Swiss train stations by name or location.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
typeNostation

Implementation Reference

  • The main handler function that implements the ch_search_stations tool logic. It validates the query, prepares API parameters, fetches data from the Swiss transport API, and handles errors.
    async def ch_search_stations( query: str, type: Optional[str] = "station" ) -> Dict[str, Any]: """Search for Swiss stations by name.""" if not query or not query.strip(): raise ValueError("Search query cannot be empty") params = { "query": query.strip(), "type": type or "station" } try: logger.info(f"Searching stations: {query}") return await fetch_json(f"{CH_BASE_URL}/locations", params) except TransportAPIError as e: logger.error(f"CH station search failed: {e}") raise
  • tools/ch.py:62-65 (registration)
    The @mcp.tool decorator that registers the ch_search_stations function as an MCP tool with its name and description.
    @mcp.tool( name="ch_search_stations", description="Search for Swiss train stations by name or location." )
  • tools/ch.py:139-144 (registration)
    The register_ch_tools function returns a list of tool functions including ch_search_stations for registration with the MCP server.
    return [ ch_search_connections, ch_search_stations, ch_get_departures, ch_nearby_stations ]
  • server.py:50-50 (registration)
    Top-level registration in the server main function, calling register_ch_tools to add the CH tools (including ch_search_stations) to the MCP instance.
    ch_tools = register_ch_tools(mcp)

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/mirodn/mcp-server-public-transport'

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