Skip to main content
This cookbook demonstrates how to set up and leverage OpenAI Agents combined with Dappier MCP for dynamic travel planning. By integrating real-time data and automated tool orchestration via the Model Context Protocol (MCP), this notebook walks you through a practical approach to building adaptive travel agents. In this cookbook, you’ll explore:
  • OpenAI Agents SDK: A powerful toolkit that enables large language models to operate as autonomous agents, use tools, and execute multi-step workflows with memory and structured decision-making.
  • 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.
  • 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: Install Python Packages Install OpenAI Agents SDK.

🔑 Setting Up API Keys

You’ll need API keys for both Dappier and OpenAI to authenticate your requests and access tools. Dappier API Key Head to Dappier to sign up and generate your API key. Dappier offers free credits to get started. You can set your API key as an environment variable in your terminal:
Or programmatically in your Python script:
Python

OpenAI API Key Visit OpenAI to retrieve your API key. Set it in your terminal:
Or in your Python script:
Python

⚙️ Import Dependencies

Start by importing all required modules to build the travel planner agent. This includes components from the OpenAI Agents SDK and the Dappier MCP server.
Python
These imports enable:
  • Running the MCP server locally via MCPServerStdio
  • Tracing and managing the agent’s execution with Runner and trace
  • Streaming the assistant’s output using ResponseTextDeltaEvent

📝 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 agent, formulates the user query, and streams the response using tools served via Dappier MCP.
Python

🚦 Initialize and Launch the Workflow

The main() function sets up the Dappier MCP server, enables tracing for observability, and runs the travel planning agent.
Python

🧪 Run the Travel Planner Agent

This block checks for the required uvx binary and launches the full async workflow. Make sure uvx is installed and available in your system path.
Python

🌟 Highlights

This cookbook has guided you through setting up and running a dynamic travel planner using OpenAI Agents and the Dappier MCP Server. By connecting your agent to real-time tools via MCP, you’ve created an assistant capable of generating rich, up-to-date itineraries that adapt to weather, events, and deals. Key components of this workflow include:
  • OpenAI Agents SDK: A powerful toolkit that enables large language models to operate as autonomous agents, use tools, and execute multi-step workflows with memory and structured decision-making.
  • 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.
  • 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 architecture can be adapted to other use cases requiring live data integration, intelligent tool use, and context-aware output generation using the Agents SDK and MCP ecosystem.