- 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 search, financial data, stock tickers, content recommendations, AI-powered summaries, and more. Dappier MCP acts as a gateway to trusted data and intelligent utilities your agent can use dynamically.
- Real-Time Stock Analysis: A practical use case where the agent analyzes a user-selected tech sector, pulls live financial signals, and generates a smart, explainable investment strategy with top stock picks.
π¦ 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 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
π Define User Input
Weβll collect the tech sector the user is interested in analyzing.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
Themain() function sets up the Dappier MCP server, enables tracing for observability, and runs the stock analysis 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 stock analyst 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 analyzing sector-specific trends and recommending investment strategies grounded in live data. 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 financial news, stock tickers, earnings data, live search, and content recommendations.
- AI Stock Analysis: A real-world use case where the assistant analyzes a user-selected tech sector, gathers current financial signals, and returns a detailed, data-backed investment strategy with top stock picks.

