StockMCP
Integrates Yahoo Finance API with LLaMA 3.2 3B, allowing users to retrieve real-time stock prices, company information, historical data, and market news while maintaining the model's original capabilities.
Integrates Yahoo Finance API with LLaMA 3.2 3B, allowing users to retrieve real-time stock prices, company information, historical data, and market news while maintaining the model's original capabilities.
This repository contains a Model Context Protocol (MCP) implementation that integrates Yahoo Finance API with LLaMA 3.2 3B. The MCP allows the model to retrieve real-time financial data, stock information, and market news while preserving all of LLaMA's regular capabilities.
Install Ollama from https://ollama.ai/
Pull the LLaMA 3.2 3B model using Ollama:
ollama pull llama3.2:3b
Clone this repository:
git clone <repository-url>
cd mcp_yahoo_finance
Install the required Python dependencies:
pip install -r requirements.txt
To use the Yahoo Finance MCP with LLaMA 3.2 3B through Ollama:
python mcp_ollama_integration.py
This will start an interactive session where you can: - Ask financial questions that will be enriched with Yahoo Finance data - Ask any other questions which will be handled normally by LLaMA 3.2 3B
You can specify a different model with the --model
parameter:
python mcp_ollama_integration.py --model llama3.2:8b
This approach seamlessly enhances LLaMA's capabilities with real-time financial data while preserving all of its original functionality.
If you want to use the Yahoo Finance MCP functions directly in your code:
from yahoo_finance_mcp import YahooFinanceMCP
# Initialize the MCP
mcp = YahooFinanceMCP()
# Get stock price
price_data = mcp.execute_function("get_stock_price", {"symbol": "AAPL"})
# Get company information
company_data = mcp.execute_function("get_stock_info", {"symbol": "TSLA"})
# Get historical data
history_data = mcp.execute_function("get_stock_history", {"symbol": "MSFT", "period": "1mo"})
# Get market news
news_data = mcp.execute_function("get_market_news", {"limit": 5})
ollama pull llama3.2:3b
to download the modelThis project uses the yfinance library for retrieving Yahoo Finance data and Ollama for running LLaMA 3.2 3B locally.