Skip to main content
Glama
Cyreslab-AI

FlightRadar MCP Server

get_flight_data

Retrieve real-time flight status and tracking information by providing a flight number, enabling users to monitor specific flights and access current data.

Instructions

Get real-time data for a specific flight by flight number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
flight_iataNoIATA flight code (e.g., 'BA123')
flight_icaoNoICAO flight code (e.g., 'BAW123')

Implementation Reference

  • The handler function that executes the get_flight_data tool logic. It validates input, calls the AviationStack API, formats the response, and returns structured flight data.
    /**
     * Handle the get_flight_data tool
     */
    private async handleGetFlightData(args: any) {
      const params: Record<string, any> = {};
    
      if (args.flight_iata) {
        params.flight_iata = args.flight_iata;
      } else if (args.flight_icao) {
        params.flight_icao = args.flight_icao;
      } else {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Either flight_iata or flight_icao must be provided"
        );
      }
    
      const response = await this.axiosInstance.get("/flights", { params });
    
      if (!response.data.data || response.data.data.length === 0) {
        return {
          content: [
            {
              type: "text",
              text: "No flight data found for the specified flight number.",
            },
          ],
        };
      }
    
      // Format the flight data for better readability
      const flightData = response.data.data[0];
      const formattedData = {
        flight: {
          number: flightData.flight.number,
          iata: flightData.flight.iata,
          icao: flightData.flight.icao,
        },
        airline: {
          name: flightData.airline.name,
          iata: flightData.airline.iata,
          icao: flightData.airline.icao,
        },
        departure: {
          airport: flightData.departure.airport,
          iata: flightData.departure.iata,
          icao: flightData.departure.icao,
          terminal: flightData.departure.terminal,
          gate: flightData.departure.gate,
          scheduled: flightData.departure.scheduled,
          estimated: flightData.departure.estimated,
          actual: flightData.departure.actual,
        },
        arrival: {
          airport: flightData.arrival.airport,
          iata: flightData.arrival.iata,
          icao: flightData.arrival.icao,
          terminal: flightData.arrival.terminal,
          gate: flightData.arrival.gate,
          scheduled: flightData.arrival.scheduled,
          estimated: flightData.arrival.estimated,
          actual: flightData.arrival.actual,
        },
        status: flightData.flight_status,
        aircraft: flightData.aircraft,
        live: flightData.live,
      };
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(formattedData, null, 2),
          },
        ],
      };
    }
  • Input schema for the get_flight_data tool, specifying either flight_iata or flight_icao as required parameters.
    inputSchema: {
      type: "object",
      properties: {
        flight_iata: {
          type: "string",
          description: "IATA flight code (e.g., 'BA123')",
        },
        flight_icao: {
          type: "string",
          description: "ICAO flight code (e.g., 'BAW123')",
        },
      },
      oneOf: [
        { required: ["flight_iata"] },
        { required: ["flight_icao"] },
      ],
    },
  • src/index.ts:79-99 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema.
    {
      name: "get_flight_data",
      description: "Get real-time data for a specific flight by flight number",
      inputSchema: {
        type: "object",
        properties: {
          flight_iata: {
            type: "string",
            description: "IATA flight code (e.g., 'BA123')",
          },
          flight_icao: {
            type: "string",
            description: "ICAO flight code (e.g., 'BAW123')",
          },
        },
        oneOf: [
          { required: ["flight_iata"] },
          { required: ["flight_icao"] },
        ],
      },
    },
  • src/index.ts:177-178 (registration)
    Dispatch registration in the CallToolRequestHandler switch statement that routes calls to the handler.
    case "get_flight_data":
      return await this.handleGetFlightData(request.params.arguments);

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/Cyreslab-AI/flightradar-mcp-server'

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