feat: add airport search by city name, airport name, or IATA code - #115
Merged
Conversation
Owner
|
this is awesome :) will take a look! |
Contributor
Author
Thanks! |
Add search_airports() utility that fuzzy-matches queries against the existing Airport enum. Supports exact IATA codes, city name lookups (with a mapping for ~50 major cities), airport name substrings, and partial code prefixes. Exposed as: - CLI: fli airports "new york" - MCP: find_airports tool for AI assistant integration - Python: from fli.core import search_airports
- Hoist constant `query_lower not in CITY_AIRPORTS` guard outside the Priority 3 loop to avoid O(N) wasted evaluations - Guard against limit < 1 in search_airports() for direct Python callers - Return structured dict from MCP find_airports (consistent with search_flights/search_dates) - Import search_airports from fli.core instead of fli.core.airports
tmchow
force-pushed
the
feat/airport-search
branch
from
April 7, 2026 21:04
eb9bb0e to
489d534
Compare
punitarani
added a commit
that referenced
this pull request
May 12, 2026
PR #115 left an extra blank line after the find_airports MCP tool, causing `ruff format --check` to fail on main and blocking the test job (which depends on lint). Removing the line fixes both jobs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
punitarani
added a commit
that referenced
this pull request
May 12, 2026
PR #115 added the `find_airports` tool on main. After merging main into this branch, the strict-equality assertions in `test_mcp_http.py` started failing in CI because the merged tree exposes three tools, not two. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
punitarani
added a commit
that referenced
this pull request
May 12, 2026
* Setup Railway HTTP MCP deployment and add boot-up integration tests - Simplify railway.toml (remove unnecessary nixpacksPlan repo reference) - Change run_http() default host to 0.0.0.0 for containerized deployments - Add test_mcp_http.py with in-process and HTTP transport tests verifying the server boots and exposes search_flights and search_dates tools - Add mcp-http Makefile target https://claude.ai/code/session_01MkjS2kP1d43DGvqr818MkJ * Address review feedback on MCP HTTP tests - Replace `_free_port()` with an `http_mcp_url` pytest fixture that uses uvicorn `port=0` and reads back the bound port via `server.servers[0]`, eliminating the TOCTOU race between probe-close and uvicorn-bind. - Collapse duplicated server lifecycle (start / wait-for-ready / shutdown) from both HTTP tests into the shared fixture; each test shrinks to ~5 lines. - Document the `0.0.0.0` default in `run_http()` so local users know to set `HOST=127.0.0.1` for loopback-only behavior. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Add `find_airports` to expected MCP tools in HTTP boot tests PR #115 added the `find_airports` tool on main. After merging main into this branch, the strict-equality assertions in `test_mcp_http.py` started failing in CI because the merged tree exposes three tools, not two. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
search_airports()utility that looks up IATA codes from city names, airport names, or partial codes. Exposed as CLI command (fli airports), MCP tool (find_airports), and Python API (from fli.core import search_airports).Why this matters
Users must know IATA codes to use any fli command. When using fli through MCP with an AI assistant, the assistant needs to map "San Francisco" to "SFO" but fli provides no way to do this lookup. The competitor library fast-flights had an abandoned PR #66 for the same gap ("Enhance airport search to support multiple search criteria").
For MCP-powered travel agents, this is a prerequisite. You can't search flights if you don't know the airport code.
Demo
Changes
fli/core/airports.py(NEW, 152 lines) - Search function with 5-priority matching: exact IATA code, city name lookup (50+ major cities), partial city match, airport name substring, IATA prefix. City mapping covers cases where the city name isn't in the airport name (e.g., "new york" returns JFK, LGA, EWR since "John F Kennedy International Airport" doesn't contain "New York").fli/cli/commands/airports.py(NEW, 51 lines) - CLI command with rich table output and--jsonflag.fli/mcp/server.py(+36 lines) -find_airportsMCP tool so AI assistants can resolve city names to codes before callingsearch_flights.tests/core/test_airports.py(NEW, 99 lines) - 15 tests covering exact codes, city names, partial matches, edge cases.Testing
This contribution was developed with AI assistance (Codex + Claude Code).
Greptile Summary
This PR adds
search_airports()as a core utility, CLI command (fli airports), and MCP tool (find_airports) to let users (and AI agents) resolve city names or partial strings to IATA codes before calling flight search. The 5-priority matching algorithm (exact code → city map → partial city → airport name substring → IATA prefix) is well-structured and the test coverage is solid.Confidence Score: 5/5
Safe to merge; all findings are P2 style suggestions with no correctness or runtime impact.
No P0 or P1 issues found. The logic is correct, tests cover all priority levels and edge cases, and the CLI/MCP wiring is done properly. Remaining comments are minor: a redundant condition placement, missing lower-bound validation on a parameter, an inconsistent return type on one MCP tool, and an import style mismatch.
fli/core/airports.py (minor loop guard) and fli/mcp/server.py (return type inconsistency) are the only files worth a second look, but neither blocks merge.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[search_airports query] --> B{query empty?} B -- yes --> Z[return empty list] B -- no --> C[Priority 1: Exact IATA code match] C --> D{Airport enum match?} D -- yes --> E[Add with score 100] D -- no --> F[Priority 2: Exact city name lookup in CITY_AIRPORTS] E --> F F --> G{Exact city match?} G -- yes --> H[Add mapped airports with score 90] G -- no --> I[Priority 3: Partial city name match] H --> I I --> J{Any city starts with query AND query not in map?} J -- yes --> K[Add airports with score 80] J -- no --> L[Priority 4: Airport name substring scan] K --> L L --> M{query substring of any Airport.value?} M -- yes --> N[Add with score 70 minus position offset] M -- no --> O[Priority 5: IATA prefix scan] N --> O O --> P{len query <= 3?} P -- yes --> Q{Any IATA code starts with query?} Q -- yes --> R[Add with score 60] P -- no --> S[Sort by score desc then code asc] R --> S S --> T[Return results up to limit]Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "feat: add airport search by city name, a..." | Re-trigger Greptile