be_search_connections
Find real-time train connections in Belgium between two stations using iRail API. Specify origin, destination, and optional date, time, or results limit.
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 |
|---|---|---|---|
| date | No | ||
| destination | Yes | ||
| origin | Yes | ||
| results | No | ||
| time | No |
Implementation Reference
- tools/be.py:22-51 (handler)The async handler function implementing the core logic for searching train connections between two Belgian stations using the iRail API. Includes input validation and error handling.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)The @mcp.tool decorator that registers the be_search_connections tool with the MCP server, specifying its name and description.@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." ) )
- server.py:51-51 (registration)Invocation of register_be_tools(mcp) in the main server initialization, which triggers the registration of the BE tools including be_search_connections.be_tools = register_be_tools(mcp)