Skip to content

armgit / fli

Public Imported from GitHub
0

Google Flights MCP, CLI and Python Library

Add support for Streamable HTTP MCP

Punit Aranieb42bb8bb8cc
diff --git a/README.md b/README.md
index d1c15a7..b0aab8a 100644
--- a/README.md
+++ b/README.md
@@ -3,14 +3,15 @@
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?**
+> πŸš€ **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
+>
+> * **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
@@ -19,6 +20,9 @@ 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](https://github.com/punitarani/fli/blob/main/data/mcp-demo.gif)
@@ -56,31 +60,31 @@ fli --help
## Features
-- πŸ” **Powerful Search**
- - One-way 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
+* πŸ” **Powerful Search**
+ * One-way 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
@@ -149,6 +153,9 @@ 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
@@ -169,18 +176,19 @@ To use the flight search capabilities in Claude Desktop, add this configuration
```
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"
+ * "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"
### MCP Tools Available
The MCP server provides two main tools:
-- **`search_flights`**: Search for specific flights with detailed filters
-- **`search_cheap_flights`**: Find the cheapest dates across a flexible date range
+* **`search_flights`**: Search for specific flights with detailed filters
+* **`search_cheap_flights`**: Find the cheapest dates across a flexible date range
## Python API Usage
diff --git a/docs/guides/mcp.md b/docs/guides/mcp.md
new file mode 100644
index 0000000..0dc1445
--- /dev/null
+++ b/docs/guides/mcp.md
@@ -0,0 +1,29 @@
+## MCP Server (FastMCP)
+
+This project exposes flight search tools via a FastMCP server. You can run it over STDIO (default) or the streamable HTTP transport.
+
+### Run over STDIO
+
+Use the existing console script:
+
+```bash
+fli-mcp
+```
+
+### Run over HTTP (streamable)
+
+Use the new HTTP entrypoint. By default it binds to `127.0.0.1:8000`.
+
+```bash
+fli-mcp-http
+```
+
+You can override host/port by calling the function directly in Python:
+
+```python
+from fli.mcp import run_http
+
+run_http(host="0.0.0.0", port=8000)
+```
+
+Once running, the MCP endpoint is served at `/mcp/`, for example: `http://127.0.0.1:8000/mcp/`.
diff --git a/fli/mcp/__init__.py b/fli/mcp/__init__.py
index 210f9f5..801dd4e 100644
--- a/fli/mcp/__init__.py
+++ b/fli/mcp/__init__.py
@@ -4,6 +4,8 @@ from fli.mcp.server import (
CheapFlightSearchRequest,
FlightSearchRequest,
mcp,
+ run,
+ run_http,
search_cheap_flights,
search_flights,
)
@@ -14,4 +16,6 @@ __all__ = [
"search_cheap_flights",
"search_flights",
"mcp",
+ "run",
+ "run_http",
]
diff --git a/fli/mcp/server.py b/fli/mcp/server.py
index 3385f2c..5660ea0 100755
--- a/fli/mcp/server.py
+++ b/fli/mcp/server.py
@@ -376,5 +376,16 @@ def run():
mcp.run(transport="stdio")
+def run_http(host: str = "127.0.0.1", port: int = 8000) -> None:
+ """Run the MCP server over HTTP (streamable).
+
+ Args:
+ host: Host interface to bind the HTTP server.
+ port: Port to listen on.
+
+ """
+ mcp.run(transport="http", host=host, port=port)
+
+
if __name__ == "__main__":
run()
diff --git a/mkdocs.yml b/mkdocs.yml
index a62b701..86c3adf 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -101,6 +101,7 @@ nav:
- Getting Started:
- Quick Start: guides/quickstart.md
- Examples: examples/advanced.md
+ - MCP Server: guides/mcp.md
- API Reference:
- Models: api/models.md
- Search: api/search.md
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 5652a93..fdb3cea 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -49,6 +49,7 @@ dev = [
[project.scripts]
fli = "fli.cli:cli"
fli-mcp = "fli.mcp.server:run"
+fli-mcp-http = "fli.mcp.server:run_http"
[project.urls]
Homepage = "https://github.com/punitarani/fli"