JamesANZ/flight-finder-mcp
If you are the rightful owner of flight-finder-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
Flight Finder MCP Server is a robust Model Context Protocol server designed to facilitate AI-driven flight searches, pricing analysis, and booking recommendations.
Flight Finder MCP Server
A powerful Model Context Protocol (MCP) server that allows AI assistants to search for flights across multiple sources, analyze pricing patterns, and provide intelligent booking recommendations.
โจ Features
- Multi-Source Flight Search: Search flights from Skyscanner and Google Flights
- Official API Integration: Uses official APIs when available, falls back to scraping
- Advanced Web Scraping: Multiple extraction strategies to find real flight data
- Smart Date Analysis: Search across multiple dates to find the best prices
- Intelligent Insights: AI-powered analysis of flight details and pricing patterns
- Booking Links: Direct links to book flights on the respective platforms
- Price Recommendations: Data-driven suggestions for optimal booking times
๐ What the LLM Adds
The AI assistant provides significant value by:
- Multi-Date Optimization: Automatically searching multiple dates to find the best possible prices
- Intelligent Analysis: Breaking down flight details and providing actionable insights
- Smart Recommendations: Suggesting optimal booking strategies based on price trends
- Comparative Analysis: Comparing prices across different sources and dates
- User-Friendly Output: Presenting complex flight data in an easy-to-understand format
๐ ๏ธ Technology Stack
- Runtime: Node.js with TypeScript
- Protocol: Model Context Protocol (MCP)
- Testing: Jest with TypeScript support
- Dependencies: MCP SDK, Axios, Cheerio, Puppeteer (for future web scraping)
๐ฆ Installation
-
Clone the repository:
git clone <repository-url> cd flight-finder-mcp
-
Install dependencies:
npm install
-
Configure API keys (optional but recommended):
cp config.example.env .env # Edit .env and add your API keys
-
Build the project:
npm run build
๐ API Configuration
For the best experience, we recommend setting up API keys for official access:
Skyscanner API
- Apply for Skyscanner Partner API at: https://www.partners.skyscanner.net/product/travel-api
- Add your API key to the environment variables:
SKYSCANNER_API_KEY=your_api_key_here
Google Flights Alternative (SearchAPI)
- Sign up for SearchAPI at: https://www.searchapi.io/
- Add your API key to the environment variables:
SEARCHAPI_KEY=your_api_key_here
Note: Without API keys, the server will fall back to web scraping, which may be slower and less reliable.
๐ Web Scraping Capabilities
The server includes advanced web scraping capabilities with multiple extraction strategies:
Multi-Strategy Approach
- Primary Selectors: Looks for standard flight card elements
- Price Pattern Matching: Searches for price patterns in page content
- Advanced DOM Traversal: Scans for flight-related elements
- Page Source Analysis: Extracts data from HTML source and JSON
- Fallback Mock Data: Provides realistic mock data when scraping fails
Anti-Detection Features
- User Agent Rotation: Uses realistic browser user agents
- Rate Limiting: Implements delays between requests
- Dynamic Content Handling: Waits for JavaScript-rendered content
- Loading Indicator Detection: Waits for page loading to complete
Real Data Extraction
The scraping system is designed to extract actual flight prices and information from websites, not just mock data. It uses multiple fallback strategies to ensure the best chance of finding real flight information.
๐งช Testing
Run the test suite:
npm test
Run tests in watch mode:
npm run test:watch
๐ Usage
Starting the MCP Server
npm start
Or for development:
npm run dev
Available MCP Tools
1. search_flights
Search for flights from a specific source.
Parameters:
source
: Flight search source (skyscanner
orgoogle_flights
)origin
: Origin airport code (e.g.,LAX
,JFK
)destination
: Destination airport code (e.g.,SFO
,LHR
)departureDate
: Departure date inYYYY-MM-DD
formatreturnDate
: Return date (optional for one-way flights)passengers
: Passenger configurationadults
: Number of adult passengers (required)children
: Number of child passengers (optional)infants
: Number of infant passengers (optional)
cabinClass
: Cabin class preference (optional)
Example:
{
"source": "skyscanner",
"origin": "LAX",
"destination": "JFK",
"departureDate": "2024-12-01",
"returnDate": "2024-12-08",
"passengers": {
"adults": 2,
"children": 1
},
"cabinClass": "economy"
}
2. search_multiple_dates
Search for flights across multiple dates to find the best prices.
Parameters:
origin
: Origin airport codedestination
: Destination airport codedates
: Array of dates to searchpassengers
: Passenger configurationsources
: Array of sources to search (default: both)
Example:
{
"origin": "LAX",
"destination": "JFK",
"dates": ["2024-12-01", "2024-12-02", "2024-12-03"],
"passengers": {
"adults": 1
},
"sources": ["skyscanner", "google_flights"]
}
3. analyze_flight_details
Analyze flight details and provide insights.
Parameters:
itinerary
: Flight itinerary object to analyze
4. get_best_price_recommendation
Get the best price recommendation across multiple dates with analysis.
Parameters:
origin
: Origin airport codedestination
: Destination airport codedates
: Array of dates to searchpassengers
: Passenger configuration
5. find_best_monthly_flights
Find the best flights for a specific month, analyzing prices across all dates to identify optimal travel dates.
Parameters:
origin
: Origin airport code (e.g.,LAX
,JFK
)destination
: Destination airport code (e.g.,SFO
,LHR
)month
: Month to search inYYYY-MM
format (e.g.,2024-11
)passengers
: Passenger configurationcabinClass
: Cabin class preference (economy
,premium_economy
,business
,first
)sources
: Array of sources to search (default: both)includeWeekendAnalysis
: Whether to include weekend vs weekday analysis (default: true)
Example:
{
"origin": "LAX",
"destination": "JFK",
"month": "2024-11",
"passengers": {
"adults": 2
},
"cabinClass": "business",
"sources": ["skyscanner", "google_flights"],
"includeWeekendAnalysis": true
}
What this tool provides:
- Month-long price analysis: Searches every date in the specified month
- Cabin class optimization: Finds best prices for specific cabin classes (economy, business, first)
- Weekend vs weekday analysis: Identifies price patterns and optimal travel days
- Source comparison: Compares prices across different flight search engines
- Smart recommendations: AI-powered insights on when to book and which dates to avoid
- Top 5 deals: Ranked list of the best flight options for the month
๐ Examples
Running the Examples
The project includes comprehensive examples demonstrating the flight finder capabilities:
# Basic usage demo - shows core flight search functionality
npm run example
# Monthly flight search demo - demonstrates month-long analysis and cabin class optimization
npm run monthly-demo
Example Output
The monthly search demo provides comprehensive analysis like this:
๐
Monthly Flight Analysis for 2024-11
๐ Route: LAX โ JFK
โ๏ธ Cabin Class: Business
๐ Sources: skyscanner, google_flights
๐ Price Analysis:
โข Cheapest Date: 2024-11-05 at $605 on google_flights
โข Most Expensive Date: 2024-10-31 at $1026 on skyscanner
โข Average Price: $831
โข Price Range: $421
๐
Weekend vs Weekday Analysis:
โข Average Weekend Price: $916
โข Average Weekday Price: $794
โข Weekend Premium: 15%
๐ก Smart Recommendations:
โข ๐ Amazing deal found! 2024-11-05 is 27% below average price on google_flights.
โข ๐ก google_flights tends to have better prices for this route (12% below average).
๐ง Configuration
The server is configured through the following files:
tsconfig.json
: TypeScript compilation settingsjest.config.ts
: Jest testing configurationpackage.json
: Project dependencies and scripts
๐ Project Structure
flight-finder-mcp/
โโโ src/
โ โโโ types/
โ โ โโโ flight.ts # TypeScript type definitions
โ โโโ services/
โ โ โโโ skyscanner.ts # Skyscanner flight search service
โ โ โโโ google-flights.ts # Google Flights search service
โ โ โโโ flight-analyzer.ts # Flight analysis and insights service
โ โโโ index.ts # Main MCP server implementation
โโโ test/ # Unit tests
โโโ examples/ # Usage examples
โ โโโ basic-usage.ts # Basic flight search demo
โ โโโ monthly-search-demo.ts # Monthly analysis demo
โโโ build/ # Compiled JavaScript output
โโโ package.json # Project dependencies and scripts
โโโ tsconfig.json # TypeScript configuration
โโโ jest.config.ts # Jest testing configuration
โโโ LICENSE # MIT License
โโโ README.md # This file
๐ฎ Future Enhancements
- Real API Integration: Replace mock data with actual Skyscanner and Google Flights APIs
- Web Scraping: Implement proper web scraping for real-time flight data
- Additional Sources: Support for more flight search engines
- Price Alerts: Set up price monitoring and notifications
- Historical Data: Track price trends over time
- Route Optimization: Suggest optimal routes with stopovers
โ ๏ธ Important Notes
Current Implementation: This is a proof-of-concept implementation that uses mock data. In production, you would need to:
- Use official APIs where available
- Implement proper web scraping with rate limiting
- Respect robots.txt and terms of service
- Handle API rate limits and quotas
- Implement proper error handling and retry logic
๐ License
This project is licensed under the MIT License - see the file for details.
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ Support
For questions or support, please open an issue in the repository.
Built with โค๏ธ for the MCP community