Add Stock Price Tool to AI Agent
Quick Start
1
Install Dependencies
Create a conda environment and install the required packages:
2
Set API Key
Set your OpenAI API key as an environment variable in your terminal:
3
Create the MCP Server
Create a new file
stock_price_server.py
with the following code:4
Create the Agent
Create a new file
stock_price_agent.py
with the following code:5
Run the Agent
Execute your script:
Requirements
- Python 3.10 or higher
- yfinance package
- mcp-python-sdk package
- praisonaiagents package
- OpenAI API key (for the agent’s LLM)