Skip to main content
Glama

ch_get_departures

Retrieve real-time departure schedules for Swiss train stations to plan journeys and check upcoming train times.

Instructions

Get departure board for a Swiss train station with real-time information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stationYes
limitNo
datetimeNo

Implementation Reference

  • The core handler function implementing the ch_get_departures tool. Cleans station name, builds parameters for the Swiss transport API (/stationboard endpoint), fetches JSON data, and handles errors.
    async def ch_get_departures( station: str, limit: Optional[int] = 10, datetime: Optional[str] = None ) -> Dict[str, Any]: """Get departures from a Swiss train station.""" station_clean = validate_station_name(station) params = { "station": station_clean, "limit": limit or 10 } if datetime: params["datetime"] = datetime try: logger.info(f"Getting departures for: {station}") return await fetch_json(f"{CH_BASE_URL}/stationboard", params) except TransportAPIError as e: logger.error(f"CH departures fetch failed: {e}") raise
  • tools/ch.py:86-89 (registration)
    The @mcp.tool decorator that registers the ch_get_departures function as an MCP tool with its name and description.
    @mcp.tool( name="ch_get_departures", description="Get departure board for a Swiss train station with real-time information." )
  • tools/ch.py:139-144 (registration)
    The register_ch_tools function returns a list of registered tool functions, including ch_get_departures.
    return [ ch_search_connections, ch_search_stations, ch_get_departures, ch_nearby_stations ]
  • server.py:50-50 (registration)
    In the main server initialization, register_ch_tools(mcp) is called to register all CH tools, including ch_get_departures, with the MCP server 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