Skip to main content
Glama
Pradumnasaraf

Aviationstack MCP Server

flight_arrival_departure_schedule

Retrieve current-day arrival or departure schedules for any airport, with optional airline filtering. Get random sample flights for real-time updates.

Instructions

Return current-day arrival or departure schedule samples for an airport, optionally filtered by airline name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
airport_iata_codeYesAirport IATA code (for example: SFO).
schedule_typeYesSchedule type: arrival or departure.
airline_nameNoOptional airline name filter.
number_of_flightsNoNumber of random flights to return.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Decorator registration of the tool 'flight_arrival_departure_schedule' via @mcp.tool(), mapping it to the wrapper function flight_arrival_departure_schedule_tool.
    @mcp.tool(
        name="flight_arrival_departure_schedule",
        description=(
            "Return current-day arrival or departure schedule samples for an airport, "
            "optionally filtered by airline name."
        ),
    )
  • Core handler function that fetches current-day arrival/departure schedules from the AviationStack API, validates inputs, fetches data, samples flights, and returns JSON.
    def flight_arrival_departure_schedule(
        airport_iata_code: str,
        schedule_type: str,
        airline_name: str,
        number_of_flights: int,
    ) -> str:
        """Get a random sample of current-day arrival/departure schedules for an airport."""
        try:
            _validate_positive_int(number_of_flights, "number_of_flights")
            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}
            if airline_name:
                params["airline_name"] = airline_name
    
            data = fetch_flight_data("timetable", 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_estimated_time": _safe_get(
                            flight, "departure", "estimatedTime"
                        ),
                        "departure_scheduled_time": _safe_get(
                            flight, "departure", "scheduledTime"
                        ),
                        "departure_actual_time": _safe_get(flight, "departure", "actualTime"),
                        "departure_terminal": _safe_get(flight, "departure", "terminal"),
                        "departure_gate": _safe_get(flight, "departure", "gate"),
                        "arrival_estimated_time": _safe_get(flight, "arrival", "estimatedTime"),
                        "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"),
                        "departure_delay": _safe_get(flight, "departure", "delay"),
                    }
                )
            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 schedule", exc)
        except (KeyError, ValueError, TypeError) as exc:
            return _error_response("fetching flight schedule", exc)
  • Pydantic input schema (FlightArrivalDepartureScheduleInput) defining fields: airport_iata_code, schedule_type, airline_name, number_of_flights.
    class FlightArrivalDepartureScheduleInput(BaseModel):
        """Input schema for flight_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_name: str = Field(
            default="",
            description="Optional airline name filter.",
        )
        number_of_flights: int = Field(
            ...,
            description="Number of random flights to return.",
            gt=0,
        )
  • Tool wrapper function that validates inputs via the Pydantic schema, then delegates to the core handler function flight_arrival_departure_schedule.
    def flight_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_name: Annotated[str, Field(description="Optional airline name filter.")] = "",
        number_of_flights: Annotated[
            int, Field(description="Number of random flights to return.", gt=0)
        ] = 5,
    ) -> str:
        """Tool wrapper for flight_arrival_departure_schedule."""
        validated_input = FlightArrivalDepartureScheduleInput(
            airport_iata_code=airport_iata_code,
            schedule_type=schedule_type,
            airline_name=airline_name,
            number_of_flights=number_of_flights,
        )
        return flight_arrival_departure_schedule(
            airport_iata_code=validated_input.airport_iata_code,
            schedule_type=validated_input.schedule_type,
            airline_name=validated_input.airline_name,
            number_of_flights=validated_input.number_of_flights,
        )
Behavior3/5

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

No annotations are provided, so the description must convey behavioral traits. It states 'current-day' and implies sampling, but does not explicitly mention that results are random (only clarified in the parameter description). It also does not disclose any limitations, permissions, or rate limits. Partial disclosure, but gaps remain.

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 a single, well-structured sentence with no wasted words. It conveys the core purpose efficiently.

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 has 4 parameters and an output schema, the description is minimal. It does not mention the random sampling nature (though schema does) or provide any context about the output. Adequate but not enriched.

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%, and the parameter descriptions are clear. The description adds 'current-day' and 'schedule samples' context, but does not significantly enhance meaning beyond the schema. 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 specifies 'Return current-day arrival or departure schedule samples for an airport, optionally filtered by airline name.' It clearly identifies the verb (Return), resource (schedule samples), and scope (current-day, airport). This distinguishes it from sibling tools like 'future_flights_arrival_departure_schedule' and 'historical_flights_by_date'.

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?

The description provides no explicit guidance on when to use this tool versus alternatives. It does not mention when not to use it or compare it to sibling tools. The context signals show sibling names, but the description itself lacks usage direction.

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