Skip to main content
Glama
variflight

Variflight Tripmatch MCP Server

Official
by variflight

searchFlightsByDepArr

Search for flights between airports or cities using IATA codes and specific dates to find available travel options.

Instructions

Search for flights between airports or cities by date. For cities with multiple airports, use depcity and arrcity parameters; otherwise use dep and arr parameters. Date must be in YYYY-MM-DD format. For today's date, use the getTodayDate tool. All airport/city codes must be valid IATA 3-letter codes (e.g.BJS for city of Beijing, PEK for Beijing Capital Airport).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
depNoDeparture airport IATA 3-letter code (e.g. PEK for Beijing, CAN for Guangzhou)
depcityNoDeparture city IATA 3-letter code (e.g. BJS for Beijing, CAN for Guangzhou)
arrNoArrival airport IATA 3-letter code (e.g. SHA for Shanghai, HFE for Hefei)
arrcityNoArrival city IATA 3-letter code (e.g. SHA for Shanghai, BJS for Beijing)
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

Implementation Reference

  • The MCP tool handler function that invokes the flight service's getFlightsByDepArr method, handles errors, and returns the flight data as formatted text content.
    }, async ({ dep, depcity, arr, arrcity, date }) => {
        try {
            const flights = await flightService.getFlightsByDepArr(dep, depcity, arr, arrcity, date);
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify(flights, null, 2)
                    }
                ]
            };
        }
        catch (error) {
            console.error('Error searching flights by dep/arr:', error);
            return {
                content: [{ type: "text", text: `Error: ${error.message}` }],
                isError: true
            };
        }
    });
  • Zod schema defining the input parameters for the tool: dep, depcity, arr, arrcity, date with validation rules.
    dep: z.string()
        .length(3)
        .regex(/^[A-Z]{3}$/)
        .describe("Departure airport IATA 3-letter code (e.g. PEK for Beijing, CAN for Guangzhou)")
        .optional(),
    depcity: z.string()
        .length(3)
        .regex(/^[A-Z]{3}$/)
        .describe("Departure city IATA 3-letter code (e.g. BJS for Beijing, CAN for Guangzhou)")
        .optional(),
    arr: z.string()
        .length(3)
        .regex(/^[A-Z]{3}$/)
        .describe("Arrival airport IATA 3-letter code (e.g. SHA for Shanghai, HFE for Hefei)")
        .optional(),
    arrcity: z.string()
        .length(3)
        .regex(/^[A-Z]{3}$/)
        .describe("Arrival city IATA 3-letter code (e.g. SHA for Shanghai, BJS for Beijing)")
        .optional(),
    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")
  • dist/index.js:13-13 (registration)
    Registration of the 'searchFlightsByDepArr' tool with name, description, schema, and handler on the MCP server.
    server.tool("searchFlightsByDepArr", "Search for flights between airports or cities by date. For cities with multiple airports, use depcity and arrcity parameters; otherwise use dep and arr parameters. Date must be in YYYY-MM-DD format. For today's date, use the getTodayDate tool. All airport/city codes must be valid IATA 3-letter codes (e.g.BJS for city of Beijing, PEK for Beijing Capital Airport).", {
  • Helper method in OpenAlService that performs the API request to fetch flights by departure and arrival details.
    async getFlightsByDepArr(dep, depcity, arr, arrcity, date) {
        return this.makeRequest('flights', {
            dep,
            depcity,
            arr,
            arrcity,
            date,
        });
    }
  • Core helper method for making HTTP POST requests to the external flight API, used by getFlightsByDepArr.
    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();
    }
Behavior4/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. It discloses key behavioral traits: the tool searches flights, requires valid IATA codes, and has specific date formatting rules. However, it doesn't mention potential limitations like result pagination, error handling, or authentication needs, leaving some gaps 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.

Conciseness5/5

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

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by specific usage rules and format requirements. Every sentence adds necessary information without redundancy, making it efficient and well-structured.

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

Completeness4/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 (5 parameters, no output schema, no annotations), the description is mostly complete: it covers purpose, usage, parameter semantics, and format rules. However, it lacks details on output format (e.g., what data is returned) and error cases, which could be important for a search tool with no output schema.

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

Parameters4/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds value by explaining the semantic difference between 'dep/arr' (airport codes) and 'depcity/arrcity' (city codes), and clarifies date handling (e.g., using 'getTodayDate' for today). This goes beyond the schema's technical descriptions, but doesn't fully cover all parameter interactions.

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 tool's purpose: 'Search for flights between airports or cities by date.' It specifies the verb ('search'), resource ('flights'), and scope ('between airports or cities by date'), distinguishing it from siblings like 'searchFlightsByNumber' (which searches by flight number) and 'getFlightPriceByCities' (which focuses on prices).

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool vs. alternatives: it distinguishes between 'depcity/arrcity' for cities with multiple airports and 'dep/arr' otherwise, and explicitly mentions using 'getTodayDate' for today's date. It also implies usage for flight searches by location/date, not by number or price, which helps differentiate from sibling tools.

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