import gradio as gr import os from dotenv import load_dotenv import serpapi load_dotenv() def search_flights(departure_id: str, arrival_id: str, outbound_date: str, return_date: str, currency: str): """ Uses Google Flights API to search for flights, giving price insights, best flights and airport information params: departure_id (str): The departure airport IATA code. arrival_id (str): The arrival airport IATA code. outbound_date (str): The outbound date in YYYY-MM-DD format. return_date (str): The return date in YYYY-MM-DD format. currency (str): The currency code. """ params = { "engine": "google_flights", "departure_id": departure_id, "arrival_id": arrival_id, "outbound_date": outbound_date, "return_date": return_date, "currency": currency, "hl": "en", "api_key": os.getenv("SERP_API_KEY"), } result = serpapi.search(params) return result.as_dict() demo = gr.Interface(fn=search_flights, inputs=["text", "text", "text", "text", "text"], outputs=gr.JSON()) demo.launch(mcp_server=True)