Skip to main content
This cookbook demonstrates how to build a real-time, AI-powered travel planner using LangChain, Dappier MCP, and the lightweight **mcp-use** client. By integrating live data through the Model Context Protocol (MCP), this guide walks through how to create structured, tool-augmented agents without using the OpenAI Agents SDK. In this cookbook, you’ll explore:
  • LangChain + OpenAI: A modular framework to build LLM-powered applications with support for agents, tools, and memory.
  • Dappier MCP: A Model Context Protocol server that connects your agents to real-time, rights-cleared, AI-powered tools such as live search, weather, stock data, and content recommendations.
  • mcp-use: A lightweight Python client that bridges any LLM with any MCP server using standard transports like stdio and httpβ€”without relying on proprietary SDKs.
  • Dynamic Travel Planning: A real-world use case where the assistant creates a multi-day itinerary using live weather, events, and hotel data sourced via MCP.
This example demonstrates a flexible architecture for building real-time, tool-augmented assistants and lays the foundation for other real-world applications powered by dynamic context, tool use, and AI reasoning.

πŸ“¦ Installation

To get started, install the required tools and dependencies:
Step 1: Install uv (required to run the Dappier MCP server) macOS / Linux:
Windows:

Step 2: Create a Virtual Environment (Recommended) Create and activate a virtual environment to isolate dependencies. macOS / Linux:
Windows:

Step 3: Install Python Packages Install the necessary Python dependencies including LangChain and mcp-use.

πŸ”‘ Setting Up API Keys

You’ll need API keys for both Dappier and OpenAI to authenticate your requests and access tools.
Dappier API Key Visit Dappier to generate your API key. Dappier provides free credits to help you get started. You can set the API key as an environment variable in your terminal:
Or include it in a .env file at the root of your project:

OpenAI API Key Go to OpenAI to retrieve your API key. Set it in your terminal:
Or include it in your .env file:
In your Python script, load the .env file:
Python

βš™οΈ Import Dependencies

Start by importing the required modules to build the travel planner agent. This includes components from mcp-use, LangChain, and environment configuration.
Python
These imports enable:
  • Loading API keys from the environment using dotenv
  • Running asynchronous workflows with asyncio
  • Accessing OpenAI models via LangChain
  • Connecting to the Dappier MCP server and executing tool-augmented queries using mcp-use

πŸ“ Define User Input

We’ll collect basic trip preferences from the user: city, number of days, and travel start date.
Python

πŸ›°οΈ Run the Agent with Dappier MCP

This function sets up the MCP agent using mcp-use, formulates the travel planning query, and executes it using real-time tools provided by the Dappier MCP server.
Python

🚦 Initialize and Launch the Workflow

The main() function collects user input, then launches the asynchronous workflow to run the travel planner using mcp-use and Dappier MCP.
Python
To start the planner, run the main function using asyncio:
Python

🌟 Highlights

This cookbook has guided you through building a dynamic travel planner using LangChain, Dappier MCP, and the **mcp-use** Python client. By connecting your agent to real-time tools via MCP, you’ve created an assistant capable of generating up-to-date travel itineraries based on live weather, events, and hotel deals. Key components of this workflow include:
  • LangChain + OpenAI: A modular framework for creating LLM-powered applications with agent capabilities.
  • Dappier MCP: A Model Context Protocol server that enables access to live, rights-cleared data through AI tools like real-time search, weather, and finance.
  • mcp-use: A lightweight open-source client to connect any LLM to any MCP server using stdio or http transports, without vendor lock-in.
This architecture can be extended to other real-time applications requiring dynamic data, tool use, and intelligent orchestration powered by the MCP ecosystem.