Skip to content

Add passenger count options to CLI and MCP#103

Open
kvasdopil wants to merge 2 commits intopunitarani:mainfrom
kvasdopil:feat/passenger-count-options
Open

Add passenger count options to CLI and MCP#103
kvasdopil wants to merge 2 commits intopunitarani:mainfrom
kvasdopil:feat/passenger-count-options

Conversation

@kvasdopil
Copy link
Copy Markdown
Contributor

@kvasdopil kvasdopil commented Mar 31, 2026

Summary

  • add children, infants_in_seat, and infants_on_lap options to the fli flights and fli dates CLI commands
  • expose the same passenger fields on the MCP search_flights and search_dates tools and pass them through to PassengerInfo
  • add regression coverage for CLI, MCP, and model encoding, and update the passenger-specific docs/examples where those details are reference material

Why

The Python model layer already supported child and infant passenger counts through PassengerInfo, but the CLI and MCP surfaces still hardcoded adult-only behavior. That made family search scenarios available in the underlying library but not accessible from the main user-facing entrypoints.

Impact

Users can now specify family passenger mixes consistently across the CLI and MCP interfaces, and the docs/examples now show those options only in the places where passenger configuration is directly relevant.

Root Cause

PassengerInfo and the Google Flights encoding already handled the extra passenger fields, but the CLI command builders and MCP parameter models only exposed adult passenger counts.

Validation

  • ./.venv/bin/python -m pytest -q tests/cli tests/mcp
  • ./.venv/bin/python -m pytest -q tests/models/test_flight_search_filters.py tests/models/test_date_search_filters.py
  • ./.venv/bin/python -m ruff check examples/complex_flight_search.py examples/complex_round_trip_validation.py

Greptile Summary

This PR exposes children, infants_in_seat, and infants_on_lap passenger fields — which were already supported by PassengerInfo and the Google Flights encoding layer — through the fli flights / fli dates CLI commands and the MCP search_flights / search_dates tools. Documentation, examples, and test coverage are updated consistently.

Key changes:

  • CLI (flights.py, dates.py): three new typer.Option parameters plumbed through _search_flights_core and into PassengerInfo.
  • MCP (server.py): fields added to FlightSearchParams, DateSearchParams, and both tool function signatures with correct ge=0 Pydantic constraints.
  • Tests: new test_*_with_family_passenger_counts tests in CLI and MCP suites; model encoding tests updated to use distinct adult count (2 → 3) for clearer value differentiation.
  • Missing --passengers CLI option: both CLI commands still hardcode adults=1 with no --passengers / --adults flag. The MCP already exposes a passengers parameter, so family searches with more than one adult cannot be expressed from the CLI — this gap pre-dates the PR but is left unaddressed by it.
  • Incomplete error response in dates.py: the except (AttributeError, ValueError) handler builds its own inline query dict that omits the three new fields, while the adjacent except ParseError handler includes them, producing inconsistent JSON error responses.

Confidence Score: 5/5

Safe to merge; all findings are P2 style/completeness issues that do not affect runtime correctness of the happy path.

All P2 findings — the missing --passengers CLI option is a pre-existing gap (not introduced by this PR) and the incomplete error-response dict only affects the rarely-hit AttributeError/ValueError JSON error path. Core logic, model encoding, and the full success path are correct and covered by tests. Per guidance, P2-only findings do not reduce the score below 5.

fli/cli/commands/dates.py — the AttributeError/ValueError error handler is missing the new passenger fields in its inline query dict.

Important Files Changed

Filename Overview
fli/cli/commands/flights.py Adds --children, --infants-in-seat, --infants-on-lap CLI options and threads them through to PassengerInfo, but adults count remains hardcoded to 1 with no --passengers flag.
fli/cli/commands/dates.py Adds family passenger options correctly, but the AttributeError/ValueError error handler omits the new fields from its inline JSON query dict, creating inconsistent error responses vs. the ParseError handler.
fli/mcp/server.py Correctly adds children, infants_in_seat, and infants_on_lap to both FlightSearchParams and DateSearchParams models, and to the search_flights/search_dates tool function signatures, with proper ge=0 validation.
tests/cli/test_flights.py New test test_flights_with_family_passenger_counts verifies all three new passenger fields are correctly threaded through to the PassengerInfo object.
tests/cli/test_dates.py New test test_dates_with_family_passenger_counts mirrors the flights test and properly verifies all three new passenger fields.
tests/mcp/test_mcp_server.py Two new integration-style tests verify that children/infants fields are passed through to PassengerInfo in both search_flights and search_dates using monkeypatching; default-value assertions also added.
tests/models/test_flight_search_filters.py Test 3 changes adults from 2 to 3 to give unique values across all four passenger fields, making the encoded output [3,3,1,0] more distinguishable; the corresponding expected output is updated correctly.
tests/models/test_date_search_filters.py Same adults=2→3 change as flight filters test for consistency and distinct test data values; expected output updated correctly.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI/MCP
    participant PassengerInfo
    participant SearchEngine
    participant GoogleFlights

    User->>CLI/MCP: --children N / --infants-in-seat N / --infants-on-lap N
    CLI/MCP->>PassengerInfo: PassengerInfo(adults=1, children=N, infants_in_seat=N, infants_on_lap=N)
    PassengerInfo-->>CLI/MCP: validated model
    CLI/MCP->>SearchEngine: FlightSearchFilters(passenger_info=...)
    SearchEngine->>GoogleFlights: encode([adults, children, infants_on_lap, infants_in_seat])
    GoogleFlights-->>SearchEngine: flight results
    SearchEngine-->>CLI/MCP: FlightResult[]
    CLI/MCP-->>User: formatted output
Loading

Comments Outside Diff (1)

  1. fli/cli/commands/dates.py, line 382-419 (link)

    P2 Missing passenger fields in fallback error response

    The except (AttributeError, ValueError) handler builds its own inline query dict that omits children, infants_in_seat, and infants_on_lap. The except ParseError handler above it (lines 339–379) includes those fields, so the two branches produce inconsistent JSON error responses.

    When a ValueError or AttributeError is raised during the actual search (e.g. a network timeout re-wrapped as ValueError), the caller receives a JSON error response that silently drops the passenger configuration they supplied.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: fli/cli/commands/dates.py
    Line: 382-419
    
    Comment:
    **Missing passenger fields in fallback error response**
    
    The `except (AttributeError, ValueError)` handler builds its own inline `query` dict that omits `children`, `infants_in_seat`, and `infants_on_lap`. The `except ParseError` handler above it (lines 339–379) includes those fields, so the two branches produce inconsistent JSON error responses.
    
    When a `ValueError` or `AttributeError` is raised during the actual search (e.g. a network timeout re-wrapped as `ValueError`), the caller receives a JSON error response that silently drops the passenger configuration they supplied.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: fli/cli/commands/dates.py
Line: 382-419

Comment:
**Missing passenger fields in fallback error response**

The `except (AttributeError, ValueError)` handler builds its own inline `query` dict that omits `children`, `infants_in_seat`, and `infants_on_lap`. The `except ParseError` handler above it (lines 339–379) includes those fields, so the two branches produce inconsistent JSON error responses.

When a `ValueError` or `AttributeError` is raised during the actual search (e.g. a network timeout re-wrapped as `ValueError`), the caller receives a JSON error response that silently drops the passenger configuration they supplied.

```suggestion
    except (AttributeError, ValueError) as e:
        if "module 'fli.search' has no attribute 'SearchDates'" in str(e):
            raise
        if output_format == OutputFormat.JSON:
            emit_json(
                build_json_error_response(
                    search_type="dates",
                    message=str(e),
                    error_type="search_error",
                    query={
                        "origin": origin,
                        "destination": destination,
                        "start_date": start_date,
                        "end_date": end_date,
                        "trip_duration": trip_duration,
                        "is_round_trip": is_round_trip,
                        "children": children,
                        "infants_in_seat": infants_in_seat,
                        "infants_on_lap": infants_on_lap,
                        "cabin_class": cabin_class,
                        "max_stops": max_stops,
                        "departure_window": (
                            f"{departure_window[0]}-{departure_window[1]}"
                            if isinstance(departure_window, tuple)
                            else departure_window
                        ),
                        "airlines": airlines,
                        "sort_by_price": sort_by_price,
                        "days": [
                            day.value
                            for day in _build_selected_days(
                                monday=monday,
                                tuesday=tuesday,
                                wednesday=wednesday,
                                thursday=thursday,
                                friday=friday,
                                saturday=saturday,
                                sunday=sunday,
                            )
                        ],
                    },
                )
            )
            raise typer.Exit(1) from e
        typer.echo(f"Error: {str(e)}")
        raise typer.Exit(1) from e
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: fli/cli/commands/flights.py
Line: 102-110

Comment:
**`adults` count hardcoded to 1 in CLI**

The CLI exposes `--children`, `--infants-in-seat`, and `--infants-on-lap`, but the adult passenger count is unconditionally hardcoded to `1`. A family travelling with 2 adults and 2 children has no way to express `adults=2` through the CLI, while the MCP surface already exposes a `passengers` parameter for this.

As stated in the PR summary, the goal is to let users "specify family passenger mixes consistently across the CLI and MCP interfaces." Without a `--passengers` (or `--adults`) option, the CLI-side adult count will always be 1 regardless of the actual party size, which can produce misleading fare quotes. The same issue exists in `dates.py` (line 288).

Consider adding a `--passengers` option analogous to the MCP `passengers` field and wiring it through to `adults=passengers` in `PassengerInfo`.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat: Add passenger count options" | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

(4/5) You can add custom instructions or style guidelines for the agent here!

@kvasdopil kvasdopil marked this pull request as ready for review March 31, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant