**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
stdioandhttpβ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.
π¦ Installation
To get started, install the required tools and dependencies:Step 1: Install
uv (required to run the Dappier MCP server)
macOS / Linux:
Step 2: Create a Virtual Environment (Recommended) Create and activate a virtual environment to isolate dependencies. macOS / Linux:
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:
.env file at the root of your project:
OpenAI API Key Go to OpenAI to retrieve your API key. Set it in your terminal:
.env file:
.env file:
Python
βοΈ Import Dependencies
Start by importing the required modules to build the travel planner agent. This includes components frommcp-use, LangChain, and environment configuration.
Python
- 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 usingmcp-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
Themain() function collects user input, then launches the asynchronous workflow to run the travel planner using mcp-use and Dappier MCP.
Python
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
stdioorhttptransports, without vendor lock-in.

