ch_nearby_stations
Locate Swiss train stations near specific coordinates by providing latitude and longitude. Specify optional distance to customize search range, aiding navigation and trip planning with public transport data.
Instructions
Find nearby Swiss train stations based on coordinates (latitude, longitude).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| distance | No | ||
| latitude | Yes | ||
| longitude | Yes |
Implementation Reference
- tools/ch.py:117-137 (handler)The handler function implementing the ch_nearby_stations tool. Accepts latitude, longitude, and optional distance (default 1000m). Maps to API params with x=longitude, y=latitude, type=station, and queries the /locations endpoint via fetch_json from core.base. Includes logging and error handling with TransportAPIError.async def ch_nearby_stations( latitude: float, longitude: float, distance: Optional[int] = 1000 ) -> Dict[str, Any]: """Find nearby stations by coordinates.""" params = { "x": longitude, "y": latitude, "type": "station" } if distance: params["distance"] = distance try: logger.info(f"Finding stations near provided coordinates") return await fetch_json(f"{CH_BASE_URL}/locations", params) except TransportAPIError as e: logger.error(f"CH nearby stations search failed: {e}") raise
- tools/ch.py:113-116 (registration)MCP decorator registering the ch_nearby_stations tool with name and description. This decorator is applied within the register_ch_tools function.@mcp.tool( name="ch_nearby_stations", description="Find nearby Swiss train stations based on coordinates (latitude, longitude)." )
- server.py:50-50 (registration)Invocation of register_ch_tools(mcp) in the main server.py, which defines and registers all CH tools including ch_nearby_stations with the MCP server instance.ch_tools = register_ch_tools(mcp)