Skip to main content
Glama
variflight

Variflight Tripmatch MCP Server

Official
by variflight

searchTrainTickets

Find available train tickets between cities on specific dates using the Variflight Tripmatch MCP Server to plan travel routes.

Instructions

Search for train tickets between two cities on a specific date. Date must be in YYYY-MM-DD format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromYesDeparture city name (e.g. 合肥)
toYesArrival city name (e.g. 北京)
dateYesTravel date in YYYY-MM-DD format. IMPORTANT: If user input only cotains month and date, you should use getTodayDate tool to get the year. For today's date, use getTodayDate tool instead of hardcoding

Implementation Reference

  • dist/index.js:211-236 (registration)
    Registration of the searchTrainTickets tool, including description, input schema using Zod, and inline asynchronous handler function that invokes flightService.getTrainTickets and formats the response.
    server.tool("searchTrainTickets", "Search for train tickets between two cities on a specific date. Date must be in YYYY-MM-DD format.", { from: z.string().describe("Departure city name (e.g. 合肥)"), to: z.string().describe("Arrival city name (e.g. 北京)"), date: z.string() .regex(/^\d{4}-\d{2}-\d{2}$/) .describe("Travel date in YYYY-MM-DD format. IMPORTANT: If user input only cotains month and date, you should use getTodayDate tool to get the year. For today's date, use getTodayDate tool instead of hardcoding"), }, async ({ from, to, date }) => { try { const trainTickets = await flightService.getTrainTickets(from, to, date); return { content: [ { type: "text", text: JSON.stringify(trainTickets, null, 2) } ] }; } catch (error) { console.error('Error searching train tickets:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } });
  • The MCP tool handler function for searchTrainTickets, which calls the underlying service method and returns the result as JSON text content or error.
    }, async ({ from, to, date }) => { try { const trainTickets = await flightService.getTrainTickets(from, to, date); return { content: [ { type: "text", text: JSON.stringify(trainTickets, null, 2) } ] }; } catch (error) { console.error('Error searching train tickets:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } });
  • Zod input schema defining parameters: from (departure city), to (arrival city), date (YYYY-MM-DD format).
    from: z.string().describe("Departure city name (e.g. 合肥)"), to: z.string().describe("Arrival city name (e.g. 北京)"), date: z.string() .regex(/^\d{4}-\d{2}-\d{2}$/) .describe("Travel date in YYYY-MM-DD format. IMPORTANT: If user input only cotains month and date, you should use getTodayDate tool to get the year. For today's date, use getTodayDate tool instead of hardcoding"),
  • Helper method in OpenAlService that performs the actual API request to the 'trainStanTicket' endpoint with city names and date.
    async getTrainTickets(from, to, date) { return this.makeRequest('trainStanTicket', { 'cdep': from, 'carr': to, date }); }

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/variflight/tripmatch-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server