Skip to main content
Glama
variflight

Variflight Tripmatch MCP Server

Official
by variflight

searchFlightsByNumber

Find flight details using flight number and date. Enter airline code with flight number (like MU2157) and departure date to get departure/arrival airports, times, and status.

Instructions

Search flights by flight number and date. Flight number should include airline code (e.g. MU2157, CZ3969). dep and arr are optional, keep empty if you don't know them. Date format: YYYY-MM-DD. IMPORTANT: For today's date, you MUST use getTodayDate tool instead of hardcoding any date. Airport codes (optional) should be IATA 3-letter codes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fnumYesFlight number including airline code (e.g. MU2157, CZ3969)
dateYesFlight 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
depNoDeparture airport IATA 3-letter code (e.g. HFE for Hefei)
arrNoArrival airport IATA 3-letter code (e.g. CAN for Guangzhou)

Implementation Reference

  • Tool handler function that calls the OpenAlService to search flights by number and formats the response.
    }, async ({ fnum, date, dep, arr }) => {
        try {
            const flights = await flightService.getFlightByNumber(fnum, date, dep, arr);
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify(flights, null, 2)
                    }
                ]
            };
        }
        catch (error) {
            console.error('Error searching flights by number:', error);
            return {
                content: [{ type: "text", text: `Error: ${error.message}` }],
                isError: true
            };
        }
    });
  • Zod input schema defining parameters fnum (required), date (required), dep and arr (optional).
        fnum: z.string()
            .regex(/^[A-Z0-9]{2,3}[0-9]{1,4}$/)
            .describe("Flight number including airline code (e.g. MU2157, CZ3969)"),
        date: z.string()
            .regex(/^\d{4}-\d{2}-\d{2}$/)
            .describe("Flight 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"),
        dep: z.string()
            .length(3)
            .regex(/^[A-Z]{3}$/)
            .describe("Departure airport IATA 3-letter code (e.g. HFE for Hefei)")
            .optional(),
        arr: z.string()
            .length(3)
            .regex(/^[A-Z]{3}$/)
            .describe("Arrival airport IATA 3-letter code (e.g. CAN for Guangzhou)")
            .optional(),
    }, async ({ fnum, date, dep, arr }) => {
  • dist/index.js:58-58 (registration)
    Registration of the searchFlightsByNumber tool using server.tool, including description and linking to schema and handler.
    server.tool("searchFlightsByNumber", "Search flights by flight number and date. Flight number should include airline code (e.g. MU2157, CZ3969).  dep and arr are optional, keep empty if you don't know them. Date format: YYYY-MM-DD. IMPORTANT: For today's date, you MUST use getTodayDate tool instead of hardcoding any date. Airport codes (optional) should be IATA 3-letter codes. ", {
  • Helper method in OpenAlService that constructs parameters conditionally and calls makeRequest to the 'flight' API endpoint.
    async getFlightByNumber(fnum, date, dep, arr) {
        const params = {
            fnum,
            date,
        };
        if (dep)
            params.dep = dep;
        if (arr)
            params.arr = arr;
        return this.makeRequest('flight', params);
    }
  • Core helper method that makes POST request to the configured API baseUrl with endpoint and params, using API key from config.
    async makeRequest(endpoint, params) {
        const url = new URL(config.api.baseUrl);
        const request_body = {
            endpoint: endpoint,
            params: params
        };
        const response = await fetch(url.toString(), {
            method: 'post',
            headers: {
                'X-VARIFLIGHT-KEY': config.api.apiKey || '',
                'Content-Type': 'application/json',
            },
            body: JSON.stringify(request_body),
        });
        if (!response.ok) {
            throw new Error(`API request failed: ${response.status} ${response.statusText}`);
        }
        return response.json();
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds useful context about date handling requirements and parameter optionality, but does not cover other behavioral aspects like error handling, rate limits, authentication needs, or what the search returns (e.g., flight details, availability). The description is adequate but incomplete for a search tool.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded with the core purpose, followed by specific formatting rules and usage notes. Every sentence adds value, though the structure could be slightly improved by grouping related instructions (e.g., date rules together). It avoids redundancy and waste.

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

Completeness3/5

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

Given the tool's moderate complexity (4 parameters, search functionality) and lack of both annotations and output schema, the description is partially complete. It covers input formatting and critical usage rules well, but omits details about what the tool returns (e.g., flight data structure, error responses) and other behavioral expectations, leaving gaps for the agent.

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 parameters thoroughly. The description adds minimal value beyond the schema by reinforcing format examples (e.g., IATA codes) and the 'keep empty' guidance for optional parameters, but does not provide significant additional semantic context. This meets the baseline for high schema coverage.

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

Purpose5/5

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

The description clearly states the specific action ('Search flights') with the resource ('by flight number and date'), distinguishing it from sibling tools like 'searchFlightsByDepArr' which searches by departure/arrival airports. It provides concrete examples (e.g., MU2157, CZ3969) that reinforce the purpose.

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

Usage Guidelines4/5

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

The description provides clear context for usage with explicit instructions for handling today's date (use 'getTodayDate' tool) and optional parameters (dep/arr can be empty if unknown). However, it does not explicitly state when to use this tool versus alternatives like 'searchFlightsByDepArr', leaving some ambiguity in sibling tool differentiation.

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