- 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 tools — including live content recommendations, AI-generated summaries, trending topics, and more. In this example, we’ll use Dappier’s AI-powered recommendation tools (not live search) to generate high-quality, structured content.
- Newsletter Assistant Use Case: A practical implementation of an agent that gathers relevant, curated content across multiple lifestyle domains and organizes it into a format suitable for email delivery or blog publication.
📦 Installation
To get started, install the required tools and dependencies: Step 1: Installuv (required to run the Dappier MCP server)
macOS / Linux:
Step 2: Install Python Packages Install the OpenAI Agents SDK.
🔑 Setting Up API Keys
You’ll need API keys for both Dappier and OpenAI to authenticate your requests and access real-time 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:Python
OpenAI API Key Visit OpenAI to retrieve your API key. Set it in your terminal:
Python
⚙️ Import Dependencies
Start by importing all required modules to build the stock analyst agent. This includes components from the OpenAI Agents SDK and the Dappier MCP server.Python
- Running the MCP server locally via
MCPServerStdio - Tracing and managing the agent’s execution with
Runnerandtrace - Streaming the assistant’s output using
ResponseTextDeltaEvent
🛰️ Run the Agent with Dappier MCP
This function sets up the agent, sends a predefined query, and streams the assistant’s output using AI-powered content recommendations from Dappier MCP.Python
🚦 Initialize and Launch the Workflow
Themain() function sets up the Dappier MCP server, enables tracing for observability, and runs the Smart Content Curator agent.
Python
🧪 Run the Stock Analyst Agent
This block checks for the requireduvx 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 real-time newsletter assistant using OpenAI Agents and the Dappier MCP Server. By connecting your agent to AI-powered content recommendations via MCP, you’ve created an assistant capable of curating engaging, diverse content across lifestyle domains — without relying on real-time search. 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 content recommendations, live search, stock data, and more. In this example, the agent uses AI recommendations only, not search.
- Smart Content Curation: A real-world use case where the assistant generates a newsletter-ready digest by pulling trending topics in sports, lifestyle, and pet care using Dappier’s AI recommendation engine.

