Skip to main content
Glama
BACH-AI-Tools

Flightradar24 MCP Server

get_airport_info_full

Retrieve comprehensive airport details including full name, codes, location, elevation, country, city, state, and timezone information using IATA or ICAO airport codes.

Instructions

Returns detailed airport information: full name, ICAO and IATA codes, localization, elevation, country, city, state, timezone details. REQUIRED: code must be provided and non-empty.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesAirport IATA or ICAO code.

Implementation Reference

  • Primary MCP tool handler and registration for 'get_airport_info_full'. Extracts airport code from params, fetches data via FR24Client, formats and returns as text content, handles errors.
    server.tool(
      'get_airport_info_full',
      'Returns detailed airport information: full name, ICAO and IATA codes, localization, elevation, country, city, state, timezone details. REQUIRED: code must be provided and non-empty.',
      airportInfoFullSchema.shape,
      async (params: z.infer<typeof airportInfoFullSchema>) => {
        const { code } = params;
        try {
          console.log(`Raw params received by handler: ${JSON.stringify(params)}`);
          const airport = await fr24Client.getAirportInfoFull(code);
          return {
            content: [{
              type: 'text' as const,
              text: `Airport information (full):\n${JSON.stringify(airport, null, 2)}`
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text' as const,
              text: `Error fetching full airport info for ${code}: ${error instanceof Error ? error.message : 'Unknown error'}`
            }],
            isError: true
          };
        }
      }
    );
  • FR24Client method implementing the core API call for full airport information.
    async getAirportInfoFull(code: string): Promise<AirportFullInfo> {
      return this.makeRequest<AirportFullInfo>(`/static/airports/${ code}/full`);
    }
  • Zod input schema validation for the tool parameters.
    const airportInfoFullSchema = z.object({ code: z.string().min(1).describe('Airport IATA or ICAO code.') });
  • TypeScript interface defining the structure of full airport information returned by the API.
    export interface AirportFullInfo {
      name: string;
      iata: string;
      icao: string;
      lon: number;
      lat: number;
      elevation: number;
      country: CountryInfo;
      city: string;
      state: string | null;
      timezone: TimezoneInfo;
    }
  • Generic HTTP request helper method used by getAirportInfoFull to make authenticated API calls to Flightradar24.
    private async makeRequest<T>(endpoint: string, params?: Record<string, any>): Promise<T> {
      try {
        console.log(`Making request to ${endpoint} with params: ${JSON.stringify(params)}`);
        const response = await axios.get(`${this.baseUrl}${endpoint}`, {
          params: params,
          headers: {
            'Accept': 'application/json',
            'Accept-Version': 'v1',
            'Authorization': `Bearer ${this.apiKey}`
          }
        });
        // Handle responses nested under 'data' key, except for count endpoints and single objects
        if (response.data && response.data.data && Array.isArray(response.data.data)) {
          return response.data.data as T;
        }
        // Handle count responses
        if (response.data && typeof response.data.record_count === 'number') {
          return response.data as T;
        }
        // Handle single object responses (like flight tracks, airport info, airline info)
        if (response.data && typeof response.data === 'object' && !Array.isArray(response.data)) {
            return response.data as T;
        }
        // Fallback for unexpected structure
        return response.data as T;
      } catch (error) {
        const message = error instanceof AxiosError ? error.message : 'Unknown error';
        console.error(`API Request Failed: ${endpoint}`, error);
        throw new Error(`Failed request to ${endpoint}: ${message}`);
      }
    }

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/BACH-AI-Tools/fr24api-mcp'

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