• unwind ai
  • Posts
  • Build an AI Travel Planning Agent with MCP

Build an AI Travel Planning Agent with MCP

Fully functional multi-agent using MCP with step-by-step instructions (100% opensource)

Integrating travel services as a developer often means wrestling with a patchwork of inconsistent APIs. Each API—whether for maps, weather, bookings, or calendars—brings its own implementation challenges, authentication systems, and maintenance burdens. The travel industry's fragmented tech landscape creates unnecessary complexity that distracts from building great user experiences.

In this tutorial, we’ll build a multi-agent AI travel planner using MCP servers as universal connectors. By using MCP as a standardized layer, we can focus on creating intelligent agent behaviors rather than getting bogged down in API-specific quirks. Our application will orchestrate specialized AI agents that handle different aspects of travel planning while using external services through the MCP.

We'll be using the Agno framework to create a team of specialized AI agents that collaborate to create comprehensive travel plans, with each agent handling a specific aspect of travel planning—maps, weather, accommodations, and calendar events.

Don’t forget to share this tutorial on your social channels and tag Unwind AI (X, LinkedIn, Threads, Facebook) to support us!

What We’re Building

This Streamlit application implements a collaborative multi-agent system that creates personalized travel itineraries by leveraging various MCP servers for specialized tasks.

Features:

  • Multi-agent architecture with specialized roles, each equipped with an MCP server:

    • Maps Agent for routes, POIs, and travel times

    • Weather Agent for forecasts and activity recommendations

    • Booking Agent for accommodation options

    • Calendar Agent for scheduling and reminders

  • User preference customization

  • Comprehensive itinerary generation

  • Google Calendar integration

  • Interactive Streamlit interface

How The App Works

When a user submits travel details:

  1. The application constructs a detailed prompt with travel requirements

  2. The agent team is initiated with this prompt

  3. MCP servers provide specialized tools for each agent:

    • Maps Agent accesses Google Maps via MCP to find routes and points of interest

    • Weather Agent retrieves forecasts via a weather MCP server

    • Booking Agent searches for accommodations using the Airbnb MCP server

    • Calendar Agent uses our custom Calendar MCP to create events

  4. The agents communicate, share information, and build a comprehensive travel plan, including accommodation suggestions, activity itineraries, weather forecasts, and calendar events.

Prerequisites

Before we begin, make sure you have the following:

  1. Python installed on your machine (version 3.10 or higher is recommended)

  2. The following API keys and credentials:

    • Google Maps API Key

    • Google Calendar API credentials (Client ID, Client Secret, Refresh Token)

    • AccuWeather API Key

    • OpenAI API Key

  3. A code editor of your choice (we recommend VS Code or PyCharm for their excellent Python support)

  4. Basic familiarity with Python programming

Code Walkthrough

Setting Up the Environment

First, let's get our development environment ready:

  1. Clone the GitHub repository:

git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
cd mcp_ai_agents/ai_travel_planner_mcp_agent_team
pip install -r requirements.txt
  1. Grab your API Keys:

    • Google Maps API Key: Go to Google Cloud Console, enable Maps JavaScript API, and generate a key under "APIs & Services > Credentials".

    • Google Calendar API: Visit Google Cloud Console, enable Google Calendar API, and create OAuth 2.0 credentials.

    • Google OAuth Credentials: In Google Cloud Console, go to "APIs & Services > Credentials", then click "Create Credentials > OAuth client ID".

    • AccuWeather API Key: Sign up at developer.accuweather.com, create an app, and get your API key.

    • OpenAI API Key: Sign up at platform.openai.com, go to "API keys", and generate a new key.

Creating the Streamlit App

Let’s create our app. Create a new file app.py and add the following code:

  1. Import necessary libraries:

import asyncio
import os
from agno.agent import Agent
from agno.team.team import Team
from agno.tools.mcp import MultiMCPTools
from agno.models.openai import OpenAIChat
import streamlit as st
from datetime import date
  1. Define the function to run our agent team:

async def run_agent(message: str):
    """Run the Airbnb, Google Maps, Weather and Calendar agent with the given message."""
    # Get API keys from session state
    google_maps_key = st.session_state.get('google_maps_key')
    accuweather_key = st.session_state.get('accuweather_key')
    openai_key = st.session_state.get('openai_key')
    google_client_id = st.session_state.get('google_client_id')
    google_client_secret = st.session_state.get('google_client_secret')
    google_refresh_token = st.session_state.get('google_refresh_token')
    
    # Validate API keys...
    
    # Set up environment for MCP servers
    env = {
        **os.environ,
        "GOOGLE_MAPS_API_KEY": google_maps_key,
        "ACCUWEATHER_API_KEY": accuweather_key,
        "OPENAI_API_KEY": openai_key,
        "GOOGLE_CLIENT_ID": google_client_id,
        "GOOGLE_CLIENT_SECRET": google_client_secret,
        "GOOGLE_REFRESH_TOKEN": google_refresh_token
    }
  1. Set up our MCP tools:

async with MultiMCPTools(
    [
        "npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt", # Airbnb mcp
        "npx -y @modelcontextprotocol/server-google-maps", # Google Maps mcp
        "uvx --from git+https://github.com/adhikasp/mcp-weather.git mcp-weather", # Weather mcp
        "./calendar_mcp.py" # Our custom Calendar MCP
    ],
    env=env,
) as mcp_tools:
  1. Let’s define our specialized agents:

maps_agent = Agent(
    tools=[mcp_tools],
    model=OpenAIChat(id="gpt-4o-mini", api_key=openai_key),
    name="Maps Agent",
    goal="""As a Maps Agent, your responsibilities include:
1. Finding optimal routes between locations
2. Identifying points of interest near destinations
3. Calculating travel times and distances
4. Suggesting transportation options
5. Finding nearby amenities and services
6. Providing location-based recommendations

Always consider:
- Traffic conditions and peak hours
- Alternative routes and transportation modes
- Accessibility and convenience
- Safety and well-lit areas
- Proximity to other planned activities"""
)

weather_agent = Agent(
    tools=[mcp_tools],
    name="Weather Agent",
    model=OpenAIChat(id="gpt-4o-mini", api_key=openai_key),
    goal="""As a Weather Agent, your responsibilities include:
1. Providing detailed weather forecasts for destinations
2. Alerting about severe weather conditions
3. Suggesting weather-appropriate activities
4. Recommending the best travel times based on the weather conditions
5. Providing seasonal travel recommendations

Always consider:
- Temperature ranges and comfort levels
- Precipitation probability
- Wind conditions
- UV index and sun protection
- Seasonal variations
- Weather alerts and warnings"""
)

booking_agent = Agent(
    tools=[mcp_tools],
    name="Booking Agent",
    model=OpenAIChat(id="gpt-4o-mini", api_key=openai_key),
    goal="""As a Booking Agent, your responsibilities include:
1. Finding accommodations within budget on airbnb
2. Comparing prices across platforms
3. Checking availability for specific dates
4. Verifying amenities and policies
5. Finding last-minute deals when applicable

Always consider:
- Location convenience
- Price competitiveness
- Cancellation policies
- Guest reviews and ratings
- Amenities matching preferences
- Special requirements or accessibility needs"""
)

calendar_agent = Agent(
    tools=[mcp_tools],
    name="Calendar Agent",
    model=OpenAIChat(id="gpt-4o-mini", api_key=openai_key),
    goal="""As a Calendar Agent, your responsibilities include:
1. Creating detailed travel itineraries
2. Setting reminders for bookings and check-ins
3. Scheduling activities and reservations
4. Adding reminders for booking deadlines, check-ins, and other important events
5. Coordinating with other team members' schedules

Always consider:
- Time zone differences
- Travel duration between activities
- Buffer time for unexpected delays
- Important deadlines and check-in times
- Synchronization with other team members"""
)
  1. Set up the agent team orchestration:

team = Team(
    members=[maps_agent, weather_agent, booking_agent, calendar_agent],
    name="Travel Planning Team",
    markdown=True,
    show_tool_calls=True,
    instructions="""As a Travel Planning Team, coordinate to create comprehensive travel plans:
    # ... team instructions ...
    """
)

result = await team.arun(message)
output = result.messages[-1].content
return output
  1. Streamlit UI:

    The remaining code implements a user-friendly Streamlit interface with:

    • Input fields for travel details (source, destination, dates)

    • Budget settings

    • Preference selections

    • API key configuration in the sidebar

Create a new file calendar.py and add the following code:

Our custom MCP server for Google Calendar functionality:

#!/usr/bin/env python
import os
import json
import sys
import logging
from dotenv import load_dotenv
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from mcp.server.fastmcp import FastMCP

# ... setup code ...

mcp = FastMCP("Google Calendar MCP", dependencies=["python-dotenv", "google-api-python-client", "google-auth", "google-auth-oauthlib"])

@mcp.tool()
async def create_event(
    summary: str,
    start_time: str,
    end_time: str,
    description: str = None,
    location: str = None,
    attendees: list = None,
    reminders: dict = None
) -> str:
    """Create a calendar event with specified details"""
    # ... implementation ...

Running the App

With our code in place, it's time to launch the app.

  • In your terminal, navigate to the project folder, and run the following command

streamlit run app.py
  • Streamlit will provide a local URL (typically http://localhost:8501).

  • To use the app:

    1. Fill in your source, destination, and travel dates

    2. Set your budget and select preferences

    3. Choose accommodation type and transportation options

    4. Click "Plan My Trip"

    The AI agents will collaborate to create a comprehensive travel plan, adding events to your Google Calendar and providing a detailed itinerary.

Working Application Demo

Conclusion

You've just built a powerful multi-agent AI travel planner that uses MCP servers to integrate multiple specialized services. This tutorial shows how MCP simplifies complex integrations.

To enhance this project further, consider:

  1. Adding Voice Interface: Implement speech-to-text and text-to-speech to create a conversational travel assistant

  2. Expanding MCP Integration: Add more specialized MCP servers for restaurant reservations, flight bookings, or local event recommendations

  3. Implementing User Profiles: Store and recall user preferences for repeat users

  4. Adding Expense Tracking: Integrate with financial services to help users track and manage travel expenses

The MCP approach makes these enhancements significantly easier to implement, as you can add new capabilities by simply connecting to additional MCP servers rather than integrating with new APIs directly.

Keep experimenting with different configurations and features to build more sophisticated AI applications.

We share hands-on tutorials like this 2-3 times a week, to help you stay ahead in the world of AI. If you're serious about leveling up your AI skills and staying ahead of the curve, subscribe now and be the first to access our latest tutorials.

Don’t forget to share this tutorial on your social channels and tag Unwind AI (X, LinkedIn, Threads, Facebook) to support us!

Reply

or to participate.