Skip to main content
Glama
Pradumnasaraf

Aviationstack MCP Server

future_flights_arrival_departure_schedule

Retrieve future arrival or departure flight schedules for any airport by IATA code. Optionally filter by airline and specify the number of random flights.

Instructions

Return future arrival or departure schedule samples for an airport and date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
airport_iata_codeYesAirport IATA code (for example: SFO).
schedule_typeYesSchedule type: arrival or departure.
airline_iataNoOptional airline IATA code filter (for example: UA).
dateNoFuture date in YYYY-MM-DD format.
number_of_flightsNoNumber of random flights to return.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function that fetches future flight arrival/departure schedule data from the Aviationstack 'flightsFuture' API endpoint. Validates inputs (positive int, ISO date, schedule type), calls fetch_flight_data, samples results, and returns a JSON string of filtered flight details (airline, flight number, scheduled times, arrival airport/terminal/gate, aircraft).
    def future_flights_arrival_departure_schedule(
        airport_iata_code: str,
        schedule_type: str,
        airline_iata: str,
        date: str,
        number_of_flights: int,
    ) -> str:
        """Get a random sample of future flights for an airport and date."""
        try:
            _validate_positive_int(number_of_flights, "number_of_flights")
            _validate_iso_date(date, "date")
            normalized_schedule_type = schedule_type.lower()
            if normalized_schedule_type not in {"arrival", "departure"}:
                raise ValueError("'schedule_type' must be either 'arrival' or 'departure'.")
    
            params: dict[str, Any] = {
                "iataCode": airport_iata_code,
                "type": normalized_schedule_type,
                "date": date,
            }
            if airline_iata:
                params["airline_iata"] = airline_iata
    
            data = fetch_flight_data("flightsFuture", params)
            sampled_flights = _sample_data(data.get("data", []), number_of_flights)
    
            filtered_flights = []
            for flight in sampled_flights:
                filtered_flights.append(
                    {
                        "airline": _safe_get(flight, "airline", "name"),
                        "flight_number": _safe_get(flight, "flight", "iataNumber"),
                        "departure_scheduled_time": _safe_get(
                            flight, "departure", "scheduledTime"
                        ),
                        "arrival_scheduled_time": _safe_get(flight, "arrival", "scheduledTime"),
                        "arrival_airport_code": _safe_get(flight, "arrival", "iataCode"),
                        "arrival_terminal": _safe_get(flight, "arrival", "terminal"),
                        "arrival_gate": _safe_get(flight, "arrival", "gate"),
                        "aircraft": _safe_get(flight, "aircraft", "modelText"),
                    }
                )
            if not filtered_flights:
                return f"No flights found for iata code '{airport_iata_code}'."
            return json.dumps(filtered_flights)
        except requests.RequestException as exc:
            return _error_response("fetching flight future schedule", exc)
        except (KeyError, ValueError, TypeError) as exc:
            return _error_response("fetching flight future schedule", exc)
  • Pydantic input schema (FutureFlightsArrivalDepartureScheduleInput) for the tool. Defines fields: airport_iata_code (required), schedule_type (required, 'arrival'/'departure'), airline_iata (optional), date (required YYYY-MM-DD), number_of_flights (required, >0). Uses extra='forbid'.
    class FutureFlightsArrivalDepartureScheduleInput(BaseModel):
        """Input schema for future_flights_arrival_departure_schedule tool."""
    
        model_config = ConfigDict(extra="forbid")
    
        airport_iata_code: str = Field(
            ...,
            description="Airport IATA code (for example: SFO).",
            min_length=1,
        )
        schedule_type: str = Field(
            ...,
            description="Schedule type: arrival or departure.",
            examples=["arrival", "departure"],
        )
        airline_iata: str = Field(
            default="",
            description="Optional airline IATA code filter (for example: UA).",
        )
        date: str = Field(
            ...,
            description="Future date in YYYY-MM-DD format.",
            examples=["2026-03-01"],
        )
        number_of_flights: int = Field(
            ...,
            description="Number of random flights to return.",
            gt=0,
        )
  • MCP tool registration via @mcp.tool decorator. Wraps the handler with FastMCP tool metadata (name='future_flights_arrival_departure_schedule', description). The wrapper function validates inputs through the Pydantic schema, then delegates to the core handler.
    @mcp.tool(
        name="future_flights_arrival_departure_schedule",
        description="Return future arrival or departure schedule samples for an airport and date.",
    )
    def future_flights_arrival_departure_schedule_tool(
        airport_iata_code: Annotated[
            str, Field(description="Airport IATA code (for example: SFO).", min_length=1)
        ],
        schedule_type: Annotated[str, Field(description="Schedule type: arrival or departure.")],
        airline_iata: Annotated[
            str, Field(description="Optional airline IATA code filter (for example: UA).")
        ] = "",
        date: Annotated[
            str,
            Field(description="Future date in YYYY-MM-DD format.", examples=["2026-03-01"]),
        ] = "",
        number_of_flights: Annotated[
            int, Field(description="Number of random flights to return.", gt=0)
        ] = 5,
    ) -> str:
        """Tool wrapper for future_flights_arrival_departure_schedule."""
        validated_input = FutureFlightsArrivalDepartureScheduleInput(
            airport_iata_code=airport_iata_code,
            schedule_type=schedule_type,
            airline_iata=airline_iata,
            date=date,
            number_of_flights=number_of_flights,
        )
        return future_flights_arrival_departure_schedule(
            airport_iata_code=validated_input.airport_iata_code,
            schedule_type=validated_input.schedule_type,
            airline_iata=validated_input.airline_iata,
            date=validated_input.date,
            number_of_flights=validated_input.number_of_flights,
        )
  • fetch_flight_data helper used by the handler to call the Aviationstack API. Builds request with API key, makes GET request, handles errors, and returns parsed JSON payload.
    def fetch_flight_data(endpoint: str, params: dict[str, Any]) -> dict[str, Any]:
        """Fetch data from the Aviationstack API."""
        api_key = _get_api_key()
        request_params = {"access_key": api_key, **params}
        response = requests.get(f"{API_BASE_URL}/{endpoint}", params=request_params, timeout=15)
        try:
            payload = response.json()
        except ValueError:
            payload = {}
    
        if payload.get("error"):
            error = payload["error"]
            code = error.get("code", "api_error")
            error_type = error.get("type", "api_error")
            message = error.get("message", "Unknown API error")
            raise ValueError(f"{error_type} ({code}): {message}")
    
        response.raise_for_status()
        return payload
Behavior2/5

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

With no annotations, the description carries the full burden. It does not disclose that the tool returns random samples (though the schema does). No mention of API behavior, rate limits, or side effects. The word 'samples' hints at randomness but is not explicit.

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

Conciseness3/5

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

The description is a single 12-word sentence, concise but too terse. It lacks important context like date format or the random nature of results. Could be expanded slightly without losing conciseness.

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 tool has 5 parameters and an output schema, the description is insufficient. It does not mention that it returns random samples, the date format, or how to use the airline filter. The output schema might clarify return values, but the description itself is incomplete.

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 coverage is 100% with detailed parameter descriptions. The tool description adds no new information beyond the schema, such as how parameters interact or formatting details. Baseline 3 is appropriate.

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 returns future arrival or departure schedule samples for an airport and date. 'Future' distinguishes it from the sibling 'flight_arrival_departure_schedule' which likely covers current/historical data. The verb 'Return' and resource 'schedule samples' are specific.

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?

No explicit guidance on when to use this tool versus siblings like 'flight_arrival_departure_schedule' or 'historical_flights_by_date'. The description implies future use but does not explain when not to use it, nor does it mention alternatives.

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/Pradumnasaraf/aviationstack-mcp'

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