Skip to main content
Glama

duffel_search_airports

Read-onlyIdempotent

Find airport codes and details by searching airport names, city names, or validating IATA codes to ensure accurate flight searches.

Instructions

Search for airports by name, city, or IATA code.

This tool helps users find correct airport codes for flight searches by:
- Searching airport names (e.g., "Heathrow", "Charles de Gaulle")
- Searching city names (e.g., "London", "Paris")
- Validating IATA codes (e.g., "LHR", "CDG")

Results include:
- Airport name and IATA code
- City and country information
- GPS coordinates
- Time zone

Use this when:
- User provides city/airport names instead of codes
- Verifying airport codes before search
- Finding all airports in a city
- User unsure of exact airport code

Returns matching airports in specified format (JSON or Markdown).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the duffel_search_airports tool. It searches the Duffel API for airports matching the query in name, city, or IATA codes, filters results, and formats the output as JSON or Markdown.
    async def search_airports(params: SearchAirportsInput) -> str:
        """
        Search for airports by name, city, or IATA code.
        
        This tool helps users find correct airport codes for flight searches by:
        - Searching airport names (e.g., "Heathrow", "Charles de Gaulle")
        - Searching city names (e.g., "London", "Paris")
        - Validating IATA codes (e.g., "LHR", "CDG")
        
        Results include:
        - Airport name and IATA code
        - City and country information
        - GPS coordinates
        - Time zone
        
        Use this when:
        - User provides city/airport names instead of codes
        - Verifying airport codes before search
        - Finding all airports in a city
        - User unsure of exact airport code
        
        Returns matching airports in specified format (JSON or Markdown).
        """
        try:
            response = await make_api_request(
                method="GET",
                endpoint="/air/airports",
                params={"limit": 200}
            )
            
            airports = response["data"]
            query_lower = params.query.lower()
            
            matches = []
            for airport in airports:
                if (
                    query_lower in airport.get("name", "").lower() or
                    query_lower in airport.get("city_name", "").lower() or
                    query_lower == airport.get("iata_code", "").lower() or
                    query_lower in airport.get("iata_city_code", "").lower()
                ):
                    matches.append(airport)
                    if len(matches) >= params.limit:
                        break
            
            if not matches:
                return (
                    f"No airports found matching '{params.query}'.\n\n"
                    f"Try:\n"
                    f"- A different spelling\n"
                    f"- The city name instead of airport name\n"
                    f"- A broader search term"
                )
            
            if params.response_format == ResponseFormat.JSON:
                return truncate_text(format_json_response(matches))
            
            else:  # Markdown format
                lines = [
                    f"# Airport Search Results for '{params.query}'",
                    f"",
                    f"Found {len(matches)} matching airports:",
                    ""
                ]
                
                for airport in matches:
                    city = airport.get("city", {})
                    lines.append(f"## {airport.get('name', 'N/A')}")
                    lines.append(f"**IATA Code**: `{airport.get('iata_code', 'N/A')}`")
                    lines.append(f"**City**: {airport.get('city_name', 'N/A')}")
                    if city:
                        lines.append(f"**City Code**: `{city.get('iata_code', 'N/A')}`")
                    lines.append(f"**Country**: {airport.get('iata_country_code', 'N/A')}")
                    lines.append(f"**Time Zone**: {airport.get('time_zone', 'N/A')}")
                    lines.append("")
                
                return truncate_text("\n".join(lines))
                
        except Exception as e:
            return f"Error searching airports: {str(e)}\n\nTry a different search term or check your internet connection."
  • Pydantic model defining the input schema for the duffel_search_airports tool, including query, limit, and response_format fields.
    class SearchAirportsInput(BaseModel):
        """Input for searching airports by name or code."""
        model_config = ConfigDict(str_strip_whitespace=True, validate_assignment=True, extra='forbid')
    
        query: str = Field(
            ...,
            description="Search query - airport name, city, or IATA code (e.g., 'London', 'Heathrow', 'LHR')",
            min_length=2,
            max_length=100
        )
        limit: int = Field(
            default=20,
            description="Maximum number of results to return (1-100)",
            ge=1,
            le=100
        )
        response_format: ResponseFormat = Field(
            default=ResponseFormat.MARKDOWN,
            description="Output format: 'json' for raw data or 'markdown' for readable summary"
        )
  • MCP tool registration decorator that binds the search_airports handler function to the name 'duffel_search_airports' with appropriate annotations.
    @mcp.tool(
        name="duffel_search_airports",
        annotations={
            "title": "Search Airports",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": True
        }
    )
Behavior4/5

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

The description adds valuable context beyond annotations by detailing what results are included (airport name, IATA code, city/country info, GPS coordinates, time zone) and specifying return format options (JSON or Markdown). Annotations already cover read-only, open-world, idempotent, and non-destructive traits, so the description appropriately supplements with practical behavioral details without contradiction.

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 well-structured with clear sections (purpose, search methods, results, usage guidelines, return format) and every sentence adds value. It's front-loaded with the core purpose and efficiently organized without redundant information, making it easy to scan and understand.

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

Completeness5/5

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

Given the tool's moderate complexity, rich annotations, and presence of an output schema, the description provides complete contextual information. It covers purpose, usage scenarios, result details, and format options, leaving no significant gaps for an AI agent to understand and invoke the tool effectively.

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?

With 0% schema description coverage for the single parameter, the description partially compensates by explaining the search capabilities (by name, city, or IATA code) and providing examples. However, it doesn't detail the parameter's structure, required fields, or validation rules, leaving gaps in parameter understanding despite the added semantic context.

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's purpose with specific verbs ('search for airports by name, city, or IATA code') and distinguishes it from sibling tools like duffel_list_airports by emphasizing search functionality rather than listing. It explicitly mentions what resources it operates on (airports) and how it helps users find correct airport codes.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool through a dedicated 'Use this when:' section with four specific scenarios (e.g., 'User provides city/airport names instead of codes', 'Verifying airport codes before search'). It clearly differentiates use cases from potential alternatives without being misleading.

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/FortripEngineering/duffel-mcp'

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