be_search_connections
Find train routes and schedules between Belgian stations using real-time data from iRail API.
Instructions
Search train connections in Belgium between two stations. Powered by iRail API for real-time routes and schedules.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| origin | Yes | ||
| destination | Yes | ||
| results | No | ||
| date | No | ||
| time | No |
Implementation Reference
- tools/be.py:22-51 (handler)The main handler function that implements the logic for searching train connections in Belgium using the iRail API. It validates inputs, constructs API parameters, fetches data from the connections endpoint, and handles errors.async def be_search_connections( origin: str, destination: str, results: Optional[int] = 4, date: Optional[str] = None, time: Optional[str] = None ) -> Dict[str, Any]: if not origin or not origin.strip() or not destination or not destination.strip(): raise ValueError("Origin and destination must be provided and non-empty") if origin.strip() == destination.strip(): raise ValueError("Origin and destination must be different") params: Dict[str, Any] = { "from": origin.strip(), "to": destination.strip(), "format": "json", "results": results or 4 } if date: params["date"] = date if time: params["time"] = time try: logger.info(f"Searching connections: {origin.strip()} → {destination.strip()}") return await fetch_json(f"{BE_BASE_URL}/connections/", params) except TransportAPIError as e: logger.error(f"Belgium connection search failed: {e}", exc_info=True) raise
- tools/be.py:15-21 (registration)MCP tool registration decorator defining the name and description for the be_search_connections tool.@mcp.tool( name="be_search_connections", description=( "Search train connections in Belgium between two stations. " "Powered by iRail API for real-time routes and schedules." ) )
- tools/be.py:108-108 (registration)The tool function is included in the list returned by register_be_tools for MCP server registration.be_search_connections,