Skip to main content
Glama
Pradumnasaraf

Aviationstack MCP Server

list_airlines

Retrieve a paginated list of airlines, with optional search by name to find specific carriers.

Instructions

List airlines with pagination and optional search.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of airlines to return.
offsetNoOffset for pagination.
searchNoOptional airline search text for autocomplete.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function that calls the Aviationstack 'airlines' endpoint via _list_reference_data, validates inputs, and returns a JSON string of airline records.
    def list_airlines(limit: int = 10, offset: int = 0, search: str = "") -> str:
        """List airlines (supports basic-plan autocomplete through `search`)."""
        try:
            _validate_positive_int(limit, "limit")
            _validate_non_negative_int(offset, "offset")
            params: dict[str, Any] = {"limit": limit, "offset": offset}
            if search:
                params["search"] = search
    
            return _list_reference_data(
                "airlines",
                params,
                lambda airline: {
                    "airline_name": airline.get("airline_name"),
                    "iata_code": airline.get("iata_code"),
                    "icao_code": airline.get("icao_code"),
                    "callsign": airline.get("callsign"),
                    "status": airline.get("status"),
                    "country_name": airline.get("country_name"),
                    "country_iso2": airline.get("country_iso2"),
                },
            )
        except requests.RequestException as exc:
            return _error_response("fetching airlines", exc)
        except (KeyError, ValueError, TypeError) as exc:
            return _error_response("fetching airlines", exc)
  • MCP tool registration decorator that defines the 'list_airlines' tool with FastMCP and wraps the core handler with Pydantic input validation.
    @mcp.tool(
        name="list_airlines",
        description="List airlines with pagination and optional search.",
    )
    def list_airlines_tool(
        limit: Annotated[int, Field(description="Maximum number of airlines to return.", gt=0)] = 10,
        offset: Annotated[int, Field(description="Offset for pagination.", ge=0)] = 0,
        search: Annotated[
            str, Field(description="Optional airline search text for autocomplete.")
        ] = "",
    ) -> str:
        """Tool wrapper for list_airlines."""
        validated_input = ListAirlinesInput(limit=limit, offset=offset, search=search)
        return list_airlines(
            limit=validated_input.limit,
            offset=validated_input.offset,
            search=validated_input.search,
        )
  • Pydantic input schema for the list_airlines tool, defining limit, offset, and search fields with validation.
    class ListAirlinesInput(BaseModel):
        """Input schema for list_airlines tool."""
    
        model_config = ConfigDict(extra="forbid")
    
        limit: int = Field(
            default=10,
            description="Maximum number of airlines to return.",
            gt=0,
        )
        offset: int = Field(
            default=0,
            description="Offset for pagination.",
            ge=0,
        )
        search: str = Field(
            default="",
            description="Optional airline search text for autocomplete.",
        )
  • Generic helper used by list_airlines (and similar tools) to fetch reference data from an endpoint, apply a mapping function, and return JSON.
    def _list_reference_data(
        endpoint: str,
        params: dict[str, Any],
        mapper: Callable[[dict[str, Any]], dict[str, Any]],
    ) -> str:
        data = fetch_flight_data(endpoint, params)
        return json.dumps([mapper(item) for item in data.get("data", [])])
Behavior4/5

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

No annotations are provided, so the description carries the burden. The word 'list' implies read-only, but it does not explicitly state that the operation is safe or mention any behavioral traits like rate limits or authentication.

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, efficient sentence that conveys purpose and key constraints with no unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the availability of an output schema and the low complexity of the tool, the description is adequate. However, it could hint at the structure of returned data (e.g., 'returns a list of airline objects').

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?

Input schema has 100% coverage with descriptions for all three parameters. The description adds no extra meaning beyond summarizing pagination and search, so it meets the baseline of 3.

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 action ('List airlines') and key features (pagination and optional search). It distinguishes from sibling tools like list_airports and flights_with_airline by targeting a specific resource.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use (listing airlines with pagination/search) but does not explicitly mention when not to use or suggest alternatives like flights_with_airline.

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