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
        });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the date format constraint and hints at using 'getTodayDate' for today's date, but fails to describe key behaviors such as whether this is a read-only operation, what the output looks like (e.g., list of tickets, prices), error handling, or any rate limits. For a search tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with two concise sentences that directly state the tool's purpose and a key constraint. Every sentence earns its place by providing essential information without redundancy, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a search tool with no annotations and no output schema, the description is incomplete. It lacks details on output format (e.g., what data is returned), behavioral traits like error handling or pagination, and usage context relative to siblings. This leaves the agent with insufficient information to fully understand the tool's operation and results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds minimal value by reiterating the date format requirement, which is also covered in the schema's pattern and description. It does not provide additional semantic context beyond what the schema offers, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Search for train tickets between two cities on a specific date.' It specifies the verb ('search'), resource ('train tickets'), and scope ('between two cities on a specific date'), which is clear and specific. However, it does not explicitly differentiate from sibling tools like 'searchTrainStations' or 'getFlightAndTrainTransferInfo', which could cause confusion about when to use this versus alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions the date format requirement but does not indicate scenarios where this tool is preferred over siblings like 'searchTrainStations' or 'getFlightAndTrainTransferInfo'. There is no explicit context for usage, leaving the agent without direction on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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