ch_nearby_stations
Find Swiss train stations near your location using coordinates. Input latitude and longitude to discover stations within a specified distance for public transport planning.
Instructions
Find nearby Swiss train stations based on coordinates (latitude, longitude).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| latitude | Yes | ||
| longitude | Yes | ||
| distance | No |
Implementation Reference
- tools/ch.py:117-137 (handler)The main handler function implementing the ch_nearby_stations tool. It accepts latitude, longitude, and optional distance parameters, queries the Swiss transport API (/locations endpoint) for nearby stations, and handles errors.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)Registers the ch_nearby_stations tool with the MCP server using the @mcp.tool decorator, defining its name and description. The tool is also included in the return list of register_ch_tools.@mcp.tool( name="ch_nearby_stations", description="Find nearby Swiss train stations based on coordinates (latitude, longitude)." )
- tools/ch.py:117-121 (schema)Function signature defining the input schema (parameters with types) and output type for the tool.async def ch_nearby_stations( latitude: float, longitude: float, distance: Optional[int] = 1000 ) -> Dict[str, Any]: