random_aircraft_type
Fetch random aircraft type records by specifying the number of aircraft types to retrieve.
Instructions
Return random aircraft type records.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number_of_aircraft | Yes | Number of random aircraft types to return. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/aviationstack_mcp/server.py:568-587 (handler)Core handler function that fetches random aircraft types from the API, samples them, and returns JSON with aircraft_name and iata_code.
def random_aircraft_type(number_of_aircraft: int) -> str: """Get random aircraft types.""" try: _validate_positive_int(number_of_aircraft, "number_of_aircraft") data = fetch_flight_data("aircraft_types", {"limit": number_of_aircraft}) sampled_aircraft_types = _sample_data(data.get("data", []), number_of_aircraft) aircraft_types = [] for aircraft_type in sampled_aircraft_types: aircraft_types.append( { "aircraft_name": aircraft_type.get("aircraft_name"), "iata_code": aircraft_type.get("iata_code"), } ) return json.dumps(aircraft_types) except requests.RequestException as exc: return _error_response("fetching aircraft type", exc) except (KeyError, ValueError, TypeError) as exc: return _error_response("fetching aircraft type", exc) - Pydantic input schema (RandomAircraftTypeInput) validating the number_of_aircraft parameter (must be > 0).
class RandomAircraftTypeInput(BaseModel): """Input schema for random_aircraft_type tool.""" model_config = ConfigDict(extra="forbid") number_of_aircraft: int = Field( ..., description="Number of random aircraft types to return.", gt=0, ) - src/aviationstack_mcp/server.py:934-945 (registration)MCP tool registration: @mcp.tool decorator registering the tool as 'random_aircraft_type' with a description.
@mcp.tool( name="random_aircraft_type", description="Return random aircraft type records.", ) def random_aircraft_type_tool( number_of_aircraft: Annotated[ int, Field(description="Number of random aircraft types to return.", gt=0) ], ) -> str: """Tool wrapper for random_aircraft_type.""" validated_input = RandomAircraftTypeInput(number_of_aircraft=number_of_aircraft) return random_aircraft_type(number_of_aircraft=validated_input.number_of_aircraft)