Skip to main content
Glama

duffel_get_order

Read-onlyIdempotent

Retrieve complete flight booking details including order status, itinerary, passenger information, payment details, and available change options for existing travel orders.

Instructions

Retrieve complete details for an existing flight order.

This tool fetches:
- Order status and booking reference
- Flight itinerary and schedule
- Passenger information
- Payment and pricing details
- Documents and tickets
- Change and cancellation options

Use this when:
- User needs to review their booking
- Checking order status
- Before making changes or cancellations
- Retrieving booking reference for airline website

Returns order details in specified format (JSON or Markdown).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the core logic of duffel_get_order: makes API call to retrieve order details and formats the output in JSON or Markdown.
    async def get_order(params: GetOrderInput) -> str:
        """
        Retrieve complete details for an existing flight order.
        
        This tool fetches:
        - Order status and booking reference
        - Flight itinerary and schedule
        - Passenger information
        - Payment and pricing details
        - Documents and tickets
        - Change and cancellation options
        
        Use this when:
        - User needs to review their booking
        - Checking order status
        - Before making changes or cancellations
        - Retrieving booking reference for airline website
        
        Returns order details in specified format (JSON or Markdown).
        """
        try:
            response = await make_api_request(
                method="GET",
                endpoint=f"/air/orders/{params.order_id}"
            )
            
            order = response["data"]
            
            if params.response_format == ResponseFormat.JSON:
                return truncate_text(format_json_response(order))
            
            else:  # Markdown format
                lines = [
                    "# Flight Order Details",
                    "",
                    f"**Order ID**: `{order['id']}`",
                    f"**Booking Reference**: {order.get('booking_reference', 'N/A')}",
                    f"**Status**: {order.get('status', 'N/A')}",
                    f"**Total**: {format_currency(order['total_amount'], order['total_currency'])}",
                    f"**Booked**: {order.get('created_at', 'N/A')}",
                    "",
                    "## Passengers"
                ]
                
                for i, pax in enumerate(order.get("passengers", []), 1):
                    lines.append(f"{i}. {pax.get('given_name')} {pax.get('family_name')}")
                    if pax.get('born_on'):
                        lines.append(f"   - DOB: {pax['born_on']}")
                
                lines.append("")
                lines.append("## Flight Itinerary")
                
                for i, slice_info in enumerate(order.get("slices", []), 1):
                    origin = slice_info["origin"]
                    destination = slice_info["destination"]
                    lines.append(f"\n### Slice {i}: {origin['city_name']} → {destination['city_name']}")
                    lines.append(f"**Departure**: {slice_info['departure_at']} ({origin['iata_code']})")
                    lines.append(f"**Arrival**: {slice_info['arrival_at']} ({destination['iata_code']})")
                    lines.append(f"**Duration**: {format_duration(slice_info.get('duration', ''))}")
                    
                    for j, segment in enumerate(slice_info.get("segments", []), 1):
                        carrier = segment.get("marketing_carrier", {})
                        lines.append(f"\n**Flight {j}**: {carrier.get('name', 'N/A')} {segment.get('marketing_carrier_flight_number', '')}")
                        lines.append(f"- Aircraft: {segment.get('aircraft', {}).get('name', 'N/A')}")
                
                conditions = order.get("conditions", {})
                if conditions:
                    lines.append("\n## Booking Conditions")
                    
                    change_before = conditions.get("change_before_departure", {})
                    if change_before:
                        allowed = "✅ Yes" if change_before.get("allowed") else "❌ No"
                        lines.append(f"- Changes before departure: {allowed}")
                        if change_before.get("penalty_amount"):
                            penalty = format_currency(
                                change_before["penalty_amount"],
                                change_before.get("penalty_currency", "")
                            )
                            lines.append(f"  - Change fee: {penalty}")
                    
                    refund_before = conditions.get("refund_before_departure", {})
                    if refund_before:
                        allowed = "✅ Yes" if refund_before.get("allowed") else "❌ No"
                        lines.append(f"- Refund before departure: {allowed}")
                
                return truncate_text("\n".join(lines))
                
        except Exception as e:
            return f"Error retrieving order: {str(e)}\n\nTroubleshooting:\n- Verify the order ID is correct (starts with 'ord_')\n- Check if you have access to this order\n- Order might not exist or might have been cancelled"
  • Pydantic model defining the input schema for the tool: requires order_id matching 'ord_*' pattern and optional response_format.
    class GetOrderInput(BaseModel):
        """Input for retrieving order details."""
        model_config = ConfigDict(str_strip_whitespace=True, validate_assignment=True, extra='forbid')
    
        order_id: str = Field(
            ...,
            description="Duffel order ID (e.g., 'ord_00009hthhsUZ8W4LxQgkjo')",
            pattern="^ord_[a-zA-Z0-9]+$"
        )
        response_format: ResponseFormat = Field(
            default=ResponseFormat.MARKDOWN,
            description="Output format: 'json' for raw data or 'markdown' for readable summary"
        )
  • MCP tool registration decorator that registers the get_order function as the 'duffel_get_order' tool with appropriate annotations.
    @mcp.tool(
        name="duffel_get_order",
        annotations={
            "title": "Get Order Details",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": True
        }
    )
Behavior4/5

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

Annotations already cover key behavioral traits (readOnlyHint=true, destructiveHint=false, idempotentHint=true, openWorldHint=true), but the description adds valuable context by specifying what details are retrieved (e.g., 'Documents and tickets', 'Change and cancellation options') and mentioning the return format ('JSON or Markdown'), enhancing understanding beyond the annotations.

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 bullet points for fetched details and a clear 'Use this when:' section, all in a compact format. Every sentence adds value without redundancy, making it easy to scan and understand quickly.

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 complexity (retrieving flight order details), the description is complete: it covers purpose, usage guidelines, and behavioral context. With annotations providing safety and idempotency info, and an output schema handling return values, no critical gaps remain.

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 0%, but the description does not explain the single parameter (likely an order ID or reference). However, with only one parameter and high annotation coverage (e.g., openWorldHint suggests it queries existing data), the baseline is 3 as the schema must carry the burden, and the description adds no parameter-specific information.

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 specific action ('Retrieve complete details') and resource ('existing flight order'), distinguishing it from siblings like duffel_create_order (creation) and duffel_get_offer (offers). It provides a comprehensive list of what details are fetched, making the purpose explicit and differentiated.

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 includes a dedicated 'Use this when:' section with four explicit scenarios (e.g., 'User needs to review their booking', 'Before making changes or cancellations'), providing clear guidance on when to use this tool versus alternatives like duffel_create_order or duffel_search_flights.

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