Provides flight search capabilities by scraping Bing Flights, supporting one-way and round-trip searches with IATA airport codes, multiple passenger types, and various cabin classes.
Bing Flights MCP Server
A Model Context Protocol (MCP) server that scrapes flight information from Bing Flights using Playwright. This project provides both a standalone Python scraper module and an MCP server wrapper for integration with MCP-compatible applications.
π¦
Features
π Search for one-way and round-trip flights
βοΈ Support for multiple passengers (adults, children, infants)
πΊ All cabin classes (Economy, Premium Economy, Business, First)
π€ Headless or headed browser modes
π Structured JSON responses
π§ Easy integration via MCP protocol
Project Structure
Installation
Quick Start (Recommended)
The easiest way to use this MCP server is with uvx
:
This will automatically install the package and its dependencies in an isolated environment.
Installation via pip
You can also install from PyPI:
After installation, install the Playwright browser:
Development Installation
For development or if you want to modify the code:
Clone or download this repository
Create and activate a virtual environment
On Windows:
python -m venv venv venv\Scripts\activateOn macOS/Linux:
python -m venv venv source venv/bin/activateInstall dependencies
pip install -r requirements.txtInstall Playwright browsers
playwright install chromium
Usage
As an MCP Server
Using uvx (Recommended)
If you installed via PyPI, run:
Or add to your MCP settings configuration:
Running from Source
If you're developing or running from source:
Available Tools
The MCP server exposes two tools:
1.
Search for flight options from Bing Flights.
Parameters:
origin
(string, required): Origin airport code (e.g., "SEA")destination
(string, required): Destination airport code (e.g., "ICN")departure_date
(string, required): Departure date in YYYY-MM-DD formatreturn_date
(string, optional): Return date for round-trip searchesadults
(integer, optional, default=1): Number of adult passengerschildren
(integer, optional, default=0): Number of child passengersinfants
(integer, optional, default=0): Number of infant passengerscabin_class
(integer, optional, default=0): 0=Economy, 1=Premium Economy, 2=Business, 3=Firstmax_results
(integer, optional, default=10): Maximum number of resultsheadless
(boolean, optional, default=true): Run browser in headless mode
Example MCP Tool Call:
2.
Check scraper health and configuration.
Example Response:
As a Standalone Python Module
You can also use the scraper directly in your Python code:
Response Format
The scraper returns results in the following JSON structure:
Configuration Options
Cabin Classes
0
- Economy1
- Premium Economy2
- Business3
- First Class
Browser Modes
headless=True
- Browser runs in the background (faster, no UI)headless=False
- Browser window visible (useful for debugging)
Troubleshooting
Common Issues
Issue: Playwright browser not found
Issue: Timeout waiting for flight results
Issue: No results returned
Issue: Import errors
Debugging
To debug scraping issues, run with headless=False
:
This will show the browser window so you can see what's being loaded.
Running Tests
Basic Tests
Run the basic unit tests that verify module imports and URL construction:
End-to-End Tests
Run comprehensive end-to-end tests that perform actual flight searches:
Note: E2E tests make real web requests to Bing Flights and may take several minutes to complete. They include:
Invalid Parameters Test - Verifies error handling
One-Way Search Test - Real search from SEA to ICN
Round-Trip Search Test - Real search from LAX to JFK
Multiple Passengers Test - Search with 2 adults and 1 child
The tests use headless browser mode and future dates to ensure valid searches.
Technical Details
Web Scraping Approach
Uses Playwright for browser automation
Waits for dynamic content to load
Extracts data from Bing Flights result cards
Handles multiple selector patterns for robustness
Error Handling
The scraper uses minimal error handling and allows exceptions to propagate:
Network errors β Raises exception
Timeout errors β Raises
PlaywrightTimeoutError
Invalid parameters β Raises
ValueError
Parsing errors β Returns partial results or empty list
This design allows the MCP client to implement appropriate retry logic and error recovery.
Limitations
Only returns outbound flight details (return flight info not available on Bing results page)
Maximum results limited by what's visible on the initial page load
No pagination support (first page results only)
Scraping depends on Bing's page structure (may break if they change their HTML)
Dependencies
fastmcp>=0.1.0
- MCP server frameworkplaywright>=1.40.0
- Browser automationpython-dateutil>=2.8.2
- Date parsing utilities
Contributing
When contributing, please:
Test changes with both headless and headed modes
Verify compatibility with the MCP protocol
Update documentation for new features
Follow existing code style and patterns
License
MIT License - See LICENSE file for details
Disclaimer
This tool scrapes publicly available data from Bing Flights. Please:
Use responsibly and respect rate limits
Review Bing's Terms of Service
Do not use for commercial purposes without proper authorization
Be aware that web scraping may break if the website changes
Support
For issues, questions, or contributions, please open an issue on the project repository.
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables flight search and price comparison by scraping flight information from Bing Flights. Supports one-way and round-trip searches with customizable passenger counts, cabin classes, and booking details.