searchTrainStations
Find train stations by entering keywords like station names or locations to identify departure and arrival points for travel planning.
Instructions
Search for train stations by keyword.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Keyword to search for train stations (e.g. 北京西) |
Implementation Reference
- dist/index.js:271-292 (registration)Registration of the 'searchTrainStations' MCP tool, including description, Zod input schema, and handler function that invokes the service and formats the response.
server.tool("searchTrainStations", "Search for train stations by keyword.", { query: z.string().describe("Keyword to search for train stations (e.g. 北京西)"), }, async ({ query }) => { try { const trainStations = await flightService.searchTrainStations(query); return { content: [ { type: "text", text: JSON.stringify(trainStations, null, 2) } ] }; } catch (error) { console.error('Error searching train stations:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } }); - dist/index.js:271-292 (handler)The handler function for the searchTrainStations tool, which extracts the query, calls the OpenAlService method, and returns structured content or error response.
server.tool("searchTrainStations", "Search for train stations by keyword.", { query: z.string().describe("Keyword to search for train stations (e.g. 北京西)"), }, async ({ query }) => { try { const trainStations = await flightService.searchTrainStations(query); return { content: [ { type: "text", text: JSON.stringify(trainStations, null, 2) } ] }; } catch (error) { console.error('Error searching train stations:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } }); - dist/index.js:272-272 (schema)Zod schema defining the input parameter 'query' as a string for the tool.
query: z.string().describe("Keyword to search for train stations (e.g. 北京西)"), - dist/services/openalService.js:87-91 (helper)Helper method in OpenAlService class that forwards the searchTrainStations request to the backend API via makeRequest.
async searchTrainStations(query) { return this.makeRequest('searchTrainStations', { query }); } - TypeScript declaration for the searchTrainStations method signature.
searchTrainStations(query: string): Promise<any>;