Fli - 航班搜索 MCP 服务器与库 logo

Fli - 航班搜索 MCP 服务器与库

CommunityPopular
punitarani

Google Flights MCP, CLI and Python Library

Publisherpunitarani
Repositoryfli
LanguagePython
Forks
293
Stars
2.6K
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Fli - 航班搜索 MCP 服务器与库 exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    2.6K stars and 293 forks from the linked repository.

🛫 Fli - Flight Search MCP Server and Library

Ask DeepWiki

A powerful Python library that provides programmatic access to Google Flights data with an elegant CLI interface. Search flights, find the best deals, and filter results with ease.

🚀 What makes fli special? Unlike other flight search libraries that rely on web scraping, Fli directly interacts with Google Flights' API through reverse engineering. This means:

  • Fast: Direct API access means faster, more reliable results
  • Zero Scraping: No HTML parsing, no browser automation, just pure API interaction
  • Reliable: Less prone to breaking from UI changes
  • Modular: Extensible architecture for easy customization and integration

MCP Server

bash
pipx install flights

# Run the MCP server on STDIO
fli-mcp

# Run the MCP server over HTTP (streamable)
fli-mcp-http  # serves at http://127.0.0.1:8000/mcp/

MCP Demo

Connecting to Claude Desktop

json
{
  "mcpServers": {
    "fli": {
      "command": "/Users/<user>/.local/bin/fli-mcp"
    }
  }
}

Note: Replace <user> with your actual username. You can also find the path to the MCP server by running which fli-mcp in your terminal.

MCP Tools Available

The MCP server provides two main tools:

ToolDescription
search_flightsSearch for flights on a specific date with detailed filters
search_datesFind the cheapest travel dates across a flexible date range

search_flights Parameters

ParameterTypeDescription
originstringDeparture airport IATA code(s) — comma-separated for multi
destinationstringArrival airport IATA code(s) — comma-separated for multi
departure_datestringTravel date in YYYY-MM-DD format
return_datestringReturn date for round trips (optional)
cabin_classstringECONOMY, PREMIUM_ECONOMY, BUSINESS, or FIRST
max_stopsstringANY, NON_STOP, ONE_STOP, or TWO_PLUS_STOPS
departure_windowstringTime window in 'HH-HH' format (e.g., '6-20')
airlineslistFilter by airline codes (e.g., ['BA', 'AA'])
exclude_airlineslistAirline IATA codes to exclude (e.g., ['DL', 'B6'])
alliancelistRestrict to alliances: ONEWORLD, SKYTEAM, STAR_ALLIANCE
exclude_alliancelistAlliance names to exclude from results
min_layoverintMinimum layover duration in minutes (multi-stop only)
max_layoverintMaximum layover duration in minutes (multi-stop only)
currencystringISO 4217 code (e.g. 'EUR', 'JPY') — flows to curr= param
languagestringBCP-47 language code (e.g. 'en-GB') — flows to hl= param
countrystringISO 3166-1 alpha-2 country code (e.g. 'GB') for gl= param
sort_bystringCHEAPEST, DURATION, DEPARTURE_TIME, or ARRIVAL_TIME
passengersintNumber of adult passengers

search_dates Parameters

ParameterTypeDescription
originstringDeparture airport IATA code(s) — comma-separated for multi
destinationstringArrival airport IATA code(s) — comma-separated for multi
start_datestringStart of date range in YYYY-MM-DD format
end_datestringEnd of date range in YYYY-MM-DD format
trip_durationintTrip duration in days (for round-trips)
is_round_tripboolWhether to search for round-trip flights
cabin_classstringECONOMY, PREMIUM_ECONOMY, BUSINESS, or FIRST
max_stopsstringANY, NON_STOP, ONE_STOP, or TWO_PLUS_STOPS
departure_windowstringTime window in 'HH-HH' format (e.g., '6-20')
airlineslistFilter by airline codes (e.g., ['BA', 'AA'])
exclude_airlineslistAirline IATA codes to exclude
alliancelistRestrict to alliances: ONEWORLD, SKYTEAM, STAR_ALLIANCE
exclude_alliancelistAlliance names to exclude
min_layoverintMinimum layover duration in minutes
max_layoverintMaximum layover duration in minutes
currencystringISO 4217 currency code (e.g. 'EUR', 'JPY')
languagestringBCP-47 language code (e.g. 'en-GB')
countrystringISO 3166-1 alpha-2 country code (e.g. 'GB')
sort_by_priceboolSort results by price (lowest first)
passengersintNumber of adult passengers

Quick Start

bash
pip install flights
bash
# Install using pipx (recommended for CLI)
pipx install flights

# Get started with CLI
fli --help

CLI Demo

Features

  • 🔍 Powerful Search

    • One-way flight searches
    • Multi-city flight searches
    • Flexible departure times
    • Multi-airline support
    • Cabin class selection
    • Stop preferences
    • Custom result sorting
  • 💺 Cabin Classes

    • Economy
    • Premium Economy
    • Business
    • First
  • 🎯 Smart Sorting

    • Price
    • Duration
    • Departure Time
    • Arrival Time
  • 🛡️ Built-in Protection

    • Rate limiting
    • Automatic retries
    • Comprehensive error handling
    • Input validation

CLI Usage

Search for Flights

bash
# Basic flight search
fli flights JFK LHR 2026-10-25

# Advanced search with filters
fli flights JFK LHR 2026-10-25 \
    --time 6-20 \             # Departure time window (6 AM - 8 PM)
    --airlines BA,KL \        # Airlines (British Airways, KLM)
    --class BUSINESS \        # Cabin class
    --stops NON_STOP \        # Non-stop flights only
    --sort DURATION           # Sort by duration

# Alliance + exclude + locale (May-2026 filter additions)
fli flights JFK LHR 2026-10-25 \
    --alliance ONEWORLD \
    --exclude-airlines AA \
    --min-layover 90 \
    --max-layover 360 \
    --currency EUR --language en-GB --country GB

⚠️ Experimental --format json is experimental. The JSON schema may change while the machine-readable CLI contract settles.

bash
# Return machine-readable flight results
fli flights JFK LHR 2026-10-25 --format json

Find Cheapest Dates

bash
# Basic date search
fli dates JFK LHR

# Advanced search with date range
fli dates JFK LHR \
    --from 2026-01-01 \
    --to 2026-02-01 \
    --monday --friday      # Only Mondays and Fridays

⚠️ Experimental --format json is experimental for date searches as well.

bash
# Return machine-readable date search results
fli dates JFK LHR --from 2026-01-01 --to 2026-02-01 --format json

Multi-city Search

bash
# Two-leg multi-city trip
fli multi --leg SEA,HKG,2026-12-26 --leg PEK,SEA,2027-01-02

# Three-leg multi-city trip with filters
fli multi \
    -l SEA,NRT,2026-12-26 \
    -l NRT,HKG,2026-12-30 \
    -l HKG,SEA,2027-01-05 \
    --class BUSINESS \
    --stops 0

CLI Options

Flights Command (fli flights)

OptionDescriptionExample
--return, -rReturn date2026-10-30
--time, -tDeparture time window6-20
--airlines, -aAirline IATA codesBA,KL
--exclude-airlines, -AAirline IATA codes to excludeDL,B6
--allianceRestrict to alliance(s)ONEWORLD, SKYTEAM
--exclude-allianceAlliance(s) to excludeSTAR_ALLIANCE
--min-layoverMinimum layover (minutes)90
--max-layoverMaximum layover (minutes)360
--currencyISO 4217 currency codeEUR, JPY
--languageBCP-47 language code (Google hl=)en-GB
--countryISO 3166-1 alpha-2 country (gl=)GB
--class, -cCabin classECONOMY, BUSINESS
--stops, -sMaximum stopsNON_STOP, ONE_STOP
--sort, -oSort results byCHEAPEST, DURATION
--formatOutput formattext, json

Dates Command (fli dates)

OptionDescriptionExample
--fromStart date2026-01-01
--toEnd date2026-02-01
--duration, -dTrip duration in days3
--round, -RRound-trip search(flag)
--airlines, -aAirline IATA codesBA,KL
--exclude-airlines, -AAirline IATA codes to excludeDL,B6
--allianceRestrict to alliance(s)ONEWORLD
--exclude-allianceAlliance(s) to excludeSTAR_ALLIANCE
--min-layoverMinimum layover (minutes)90
--max-layoverMaximum layover (minutes)360
--currencyISO 4217 currency codeEUR, JPY
--languageBCP-47 language codeen-GB
--countryISO 3166-1 alpha-2 countryGB
--class, -cCabin classECONOMY, BUSINESS
--stops, -sMaximum stopsNON_STOP, ONE_STOP
--timeDeparture time window6-20
--sortSort by price(flag)
--[day]Day filters--monday, --friday
--formatOutput formattext, json

Multi Command (fli multi)

OptionDescriptionExample
--leg, -lFlight leg (ORIGIN,DEST,DATE format)SEA,HKG,2026-12-26
--time, -tDeparture time window6-20
--airlines, -aAirline IATA codesDL CX
--class, -cCabin classECONOMY, BUSINESS
--stops, -sMaximum stopsNON_STOP, ONE_STOP
--sort, -oSort results byCHEAPEST, DURATION

MCP Server Integration

Fli includes a Model Context Protocol (MCP) server that allows AI assistants like Claude to search for flights directly. This enables natural language flight search through conversation.

Running the MCP Server

bash
# Run the MCP server on STDIO
fli-mcp

# Or with uv (for development)
uv run fli-mcp

# Or with make (for development)
make mcp

# Run the MCP server over HTTP (streamable)
fli-mcp-http  # serves at http://127.0.0.1:8000/mcp/

Claude Desktop Configuration

To use the flight search capabilities in Claude Desktop, add this configuration to your claude_desktop_config.json:

Location: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)

json
{
  "mcpServers": {
    "flight-search": {
      "command": "fli-mcp",
      "args": []
    }
  }
}

After adding this configuration:

  1. Restart Claude Desktop
  2. You can now ask Claude to search for flights naturally:
    • "Find flights from JFK to LAX on December 25th"
    • "What are the cheapest dates to fly from NYC to London in January?"
    • "Search for business class flights from SFO to NRT with no stops"

Python API Usage

Basic Search Example

python
from datetime import datetime, timedelta
from fli.models import (
    Airport,
    PassengerInfo,
    SeatType,
    MaxStops,
    SortBy,
    FlightSearchFilters,
    FlightSegment
)
from fli.search import SearchFlights

# Create search filters
filters = FlightSearchFilters(
    passenger_info=PassengerInfo(adults=1),
    flight_segments=[
        FlightSegment(
            departure_airport=[[Airport.JFK, 0]],
            arrival_airport=[[Airport.LAX, 0]],
            travel_date=(datetime.now() + timedelta(days=30)).strftime("%Y-%m-%d"),
        )
    ],
    seat_type=SeatType.ECONOMY,
    stops=MaxStops.NON_STOP,
    sort_by=SortBy.CHEAPEST,
)

# Search flights
search = SearchFlights()
flights = search.search(filters)

# Process results
for flight in flights:
    print(f"💰 Price: ${flight.price}")
    print(f"⏱️ Duration: {flight.duration} minutes")
    print(f"✈️ Stops: {flight.stops}")

    for leg in flight.legs:
        print(f"\n🛫 Flight: {leg.airline.value} {leg.flight_number}")
        print(f"📍 From: {leg.departure_airport.value} at {leg.departure_datetime}")
        print(f"📍 To: {leg.arrival_airport.value} at {leg.arrival_datetime}")

Running Examples

We provide 11 comprehensive examples in the examples/ directory that demonstrate various use cases:

bash
# Run examples with uv (recommended)
uv run python examples/basic_one_way_search.py
uv run python examples/round_trip_search.py
uv run python examples/date_range_search.py

# Or install dependencies first, then run directly
pip install pydantic curl_cffi httpx
python examples/basic_one_way_search.py

Available Examples:

  • basic_one_way_search.py - Simple one-way flight search
  • round_trip_search.py - Round-trip flight booking
  • date_range_search.py - Find cheapest dates
  • complex_flight_search.py - Advanced filtering and multi-passenger
  • time_restrictions_search.py - Time-based filtering
  • date_search_with_preferences.py - Weekend filtering
  • price_tracking.py - Price monitoring over time
  • error_handling_with_retries.py - Robust error handling
  • result_processing.py - Data analysis with pandas
  • complex_round_trip_validation.py - Advanced round-trip with validation
  • advanced_date_search_validation.py - Complex date search with filtering

💡 Tip: Examples include automatic dependency checking and will show helpful installation instructions if dependencies are missing.

Examples

For comprehensive examples demonstrating all features, see the examples/ directory:

bash
# Quick test - run a simple example
uv run python examples/basic_one_way_search.py

# Run all examples to explore different features
uv run python examples/round_trip_search.py
uv run python examples/complex_flight_search.py
uv run python examples/price_tracking.py

Example Categories:

  • Basic Usage: One-way, round-trip, date searches
  • Advanced Filtering: Time restrictions, airlines, seat classes
  • Data Analysis: Price tracking, result processing with pandas
  • Error Handling: Retry logic, robust error management
  • Complex Scenarios: Multi-passenger, validation, business rules

Each example is self-contained and includes automatic dependency checking with helpful installation instructions.

Development

bash
# Clone the repository
git clone https://github.com/punitarani/fli.git
cd fli

# Install dependencies with uv
uv sync --all-extras

# Run tests
uv run pytest

# Run linting
uv run ruff check .
uv run ruff format .

# Build documentation
uv run mkdocs serve

# Or use the Makefile for common tasks
make install-all  # Install all dependencies
make test         # Run tests
make lint         # Check code style
make format       # Format code

Docker Development

bash
# Build the devcontainer
docker build -t fli-dev -f .devcontainer/Dockerfile .

# Run CI inside the container
docker run --rm fli-dev make lint test-all

# Or run lint and tests separately
docker run --rm fli-dev make lint
docker run --rm fli-dev make test-all

Running CI Locally with act

To run GitHub Actions locally, install act:

bash
brew install act

# Run CI locally (lint + tests on Python 3.10-3.13)
make ci

# Or run CI inside Docker (no local act installation needed)
make ci-docker

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License — see the LICENSE file for details.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "punitarani-fli": {
      "command": "uvx",
      "args": [
        "flights"
      ]
    }
  }
}

Use Fli - 航班搜索 MCP 服务器与库 MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Fli - 航班搜索 MCP 服务器与库 is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Fli - 航班搜索 MCP 服务器与库 as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Fli - 航班搜索 MCP 服务器与库 MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "punitarani-fli": {
      "command": "npx",
      "args": [
        "-y",
        "flights"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Fli - 航班搜索 MCP 服务器与库 MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Fli - 航班搜索 MCP 服务器与库 MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Fli - 航班搜索 MCP 服务器与库 to help me with this task?
Fli - 航班搜索 MCP 服务器与库
Sure. I read it.
Here is what I found using Fli - 航班搜索 MCP 服务器与库.

Frequently asked questions

What is the Fli - 航班搜索 MCP 服务器与库 MCP server used for?

Fli - 航班搜索 MCP 服务器与库 is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Fli - 航班搜索 MCP 服务器与库 MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Fli - 航班搜索 MCP 服务器与库 with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Fli - 航班搜索 MCP 服务器与库 MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Fli - 航班搜索 MCP 服务器与库 connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Fli - 航班搜索 MCP 服务器与库 MCP to TypingMind?

Fli - 航班搜索 MCP 服务器与库 runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Fli - 航班搜索 MCP 服务器与库 MCP provide in TypingMind?

Fli - 航班搜索 MCP 服务器与库 exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Fli - 航班搜索 MCP 服务器与库 MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Fli - 航班搜索 MCP 服务器与库 requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇