"""
Wisnu MCP - Travel Booking Server
A Model Context Protocol server for travel booking operations.
"""
from datetime import datetime
from typing import Literal
from fastmcp import FastMCP
# Initialize the MCP server
mcp = FastMCP("Wisnu Travel Booking 🌍")
@mcp.tool()
def search_flights(
origin: str,
destination: str,
departure_date: str,
return_date: str | None = None,
passengers: int = 1,
cabin_class: Literal["economy", "premium_economy", "business", "first"] = "economy"
) -> dict:
"""
Search for available flights between two locations.
Args:
origin: Origin airport code (e.g., "JFK", "LAX")
destination: Destination airport code (e.g., "LHR", "CDG")
departure_date: Departure date in YYYY-MM-DD format
return_date: Optional return date in YYYY-MM-DD format for round trips
passengers: Number of passengers (default: 1)
cabin_class: Cabin class preference
Returns:
Dictionary with flight search results
"""
trip_type = "round-trip" if return_date else "one-way"
return {
"search_id": f"FL-{origin}-{destination}-{datetime.now().strftime('%Y%m%d%H%M%S')}",
"origin": origin,
"destination": destination,
"departure_date": departure_date,
"return_date": return_date,
"passengers": passengers,
"cabin_class": cabin_class,
"trip_type": trip_type,
"status": "success",
"message": f"Flight search initiated for {passengers} passenger(s) from {origin} to {destination}",
"note": "This is a mock response. Connect to a real flight API for actual results."
}
@mcp.tool()
def search_hotels(
location: str,
checkin_date: str,
checkout_date: str,
guests: int = 1,
rooms: int = 1,
min_rating: float | None = None
) -> dict:
"""
Search for available hotels in a location.
Args:
location: City or location name (e.g., "Paris", "New York")
checkin_date: Check-in date in YYYY-MM-DD format
checkout_date: Check-out date in YYYY-MM-DD format
guests: Number of guests (default: 1)
rooms: Number of rooms needed (default: 1)
min_rating: Minimum hotel rating (0-5, optional)
Returns:
Dictionary with hotel search results
"""
return {
"search_id": f"HT-{location.replace(' ', '')}-{datetime.now().strftime('%Y%m%d%H%M%S')}",
"location": location,
"checkin_date": checkin_date,
"checkout_date": checkout_date,
"guests": guests,
"rooms": rooms,
"min_rating": min_rating,
"status": "success",
"message": f"Hotel search initiated for {rooms} room(s) in {location}",
"note": "This is a mock response. Connect to a real hotel API for actual results."
}
@mcp.tool()
def search_destinations(
interests: list[str],
budget_range: Literal["budget", "moderate", "luxury"] = "moderate",
season: Literal["spring", "summer", "fall", "winter", "any"] = "any"
) -> dict:
"""
Get destination recommendations based on interests and preferences.
Args:
interests: List of interests (e.g., ["beach", "culture", "adventure", "food"])
budget_range: Budget category
season: Preferred travel season
Returns:
Dictionary with destination recommendations
"""
return {
"search_id": f"DEST-{datetime.now().strftime('%Y%m%d%H%M%S')}",
"interests": interests,
"budget_range": budget_range,
"season": season,
"status": "success",
"message": f"Found destinations matching interests: {', '.join(interests)}",
"note": "This is a mock response. Connect to a real destination API for actual recommendations."
}
@mcp.tool()
def calculate_trip_cost(
flight_cost: float,
hotel_cost_per_night: float,
num_nights: int,
daily_expenses: float = 100.0,
num_travelers: int = 1
) -> dict:
"""
Calculate total estimated trip cost.
Args:
flight_cost: Cost of flights per person
hotel_cost_per_night: Hotel cost per night
num_nights: Number of nights
daily_expenses: Estimated daily expenses per person (default: $100)
num_travelers: Number of travelers (default: 1)
Returns:
Dictionary with cost breakdown
"""
total_flight = flight_cost * num_travelers
total_hotel = hotel_cost_per_night * num_nights
total_daily = daily_expenses * num_nights * num_travelers
total_cost = total_flight + total_hotel + total_daily
return {
"breakdown": {
"flights": {
"cost_per_person": flight_cost,
"total": total_flight,
"travelers": num_travelers
},
"accommodation": {
"cost_per_night": hotel_cost_per_night,
"nights": num_nights,
"total": total_hotel
},
"daily_expenses": {
"per_person_per_day": daily_expenses,
"nights": num_nights,
"travelers": num_travelers,
"total": total_daily
}
},
"total_cost": total_cost,
"currency": "USD",
"per_person_cost": total_cost / num_travelers if num_travelers > 0 else 0
}
@mcp.tool()
def get_travel_tips(
destination: str,
trip_type: Literal["business", "leisure", "adventure", "family"] = "leisure"
) -> dict:
"""
Get travel tips and recommendations for a destination.
Args:
destination: Destination city or country
trip_type: Type of trip
Returns:
Dictionary with travel tips
"""
return {
"destination": destination,
"trip_type": trip_type,
"status": "success",
"message": f"Travel tips for {trip_type} trip to {destination}",
"tips": [
"Check visa requirements well in advance",
"Purchase travel insurance",
"Research local customs and etiquette",
"Download offline maps",
"Keep digital and physical copies of important documents"
],
"note": "These are general tips. Connect to a real API for destination-specific advice."
}
if __name__ == "__main__":
# Run the MCP server
mcp.run()