Skip to main content
Glama

random_airplanes_detailed_info

Fetch detailed information about random airplanes using the Aviationstack MCP Server. Specify the number of airplanes to retrieve real-time data for research, analysis, or tracking purposes.

Instructions

MCP tool to get random airplanes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
number_of_airplanesYes

Implementation Reference

  • The handler function decorated with @mcp.tool(), which registers and implements the 'random_airplanes_detailed_info' tool. It fetches detailed information on random airplanes from the AviationStack API, processes the data, and returns it as JSON.
    @mcp.tool() def random_airplanes_detailed_info(number_of_airplanes: int) -> str: """MCP tool to get random airplanes.""" try: data = fetch_flight_data('http://api.aviationstack.com/v1/airplanes', { 'limit': number_of_airplanes }) data_list = data.get('data', []) number_of_airplanes_to_fetch = min(number_of_airplanes, len(data_list)) # Sample random airplanes from the data list sampled_airplanes = random.sample(data_list, number_of_airplanes_to_fetch) airplanes = [] for airplane in sampled_airplanes: airplanes.append({ 'production_line': airplane.get('production_line'), 'plane_owner': airplane.get('plane_owner'), 'plane_age': airplane.get('plane_age'), 'model_name': airplane.get('model_name'), 'model_code': airplane.get('model_code'), 'plane_series': airplane.get('plane_series'), 'registration_number': airplane.get('registration_number'), 'engines_type': airplane.get('engines_type'), 'engines_count': airplane.get('engines_count'), 'delivery_date': airplane.get('delivery_date'), 'first_flight_date': airplane.get('first_flight_date'), }) return json.dumps(airplanes) except requests.RequestException as e: return f"Request error: {str(e)}" except (KeyError, ValueError, TypeError) as e: return f"Error fetching airplanes: {str(e)}"
  • Shared helper function used by the tool (and others) to fetch data from the AviationStack API by adding the API key and making the HTTP request.
    def fetch_flight_data(url: str, params: dict) -> dict: """Fetch flight data from the AviationStack API.""" api_key = os.getenv('AVIATION_STACK_API_KEY') if not api_key: raise ValueError("AVIATION_STACK_API_KEY not set in environment.") params = {'access_key': api_key, **params} response = requests.get(url, params=params, timeout=10) response.raise_for_status() return response.json()

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