
Yahoo Finance MCP for LLaMA 3.2 3B
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.
README
Yahoo Finance Model Context Protocol (MCP) for LLaMA 3.2 3B
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.
Features
- Get real-time stock prices directly within LLaMA 3.2 3B
- Retrieve detailed company information (sector, industry, market cap, etc.)
- Fetch historical stock data with customizable time periods and intervals
- Get latest market news headlines
- Seamlessly enhances LLaMA's capabilities without interfering with non-financial queries
Requirements
- Python 3.8+
- Ollama - For running LLaMA 3.2 3B locally
- LLaMA 3.2 3B model pulled in Ollama
- Python packages:
- ollama
- yfinance
- requests
- pandas
Installation
-
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
Usage
Running the MCP with Ollama Integration
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
Example Queries
Financial Queries (Enhanced with Yahoo Finance data)
- "What is the current price of Apple stock?"
- "Tell me about Tesla as a company"
- "How has Microsoft's stock performed over the past month?"
- "What are the latest market news headlines?"
- "What is the 52-week high for Amazon?"
- "What sector does Nvidia operate in?"
- "How has the S&P 500 performed this year?"
Non-Financial Queries (Handled normally by LLaMA)
- "What is the capital of France?"
- "Explain quantum computing"
- "Write a poem about autumn"
- "What is the Pythagorean theorem?"
Using a Different LLaMA Model
You can specify a different model with the --model
parameter:
python mcp_ollama_integration.py --model llama3.2:8b
How It Works
- The MCP analyzes each user query to determine if it's finance-related
- For financial queries, it:
- Identifies the relevant financial function to call (price, info, history, news)
- Calls the Yahoo Finance API through the MCP
- Formats the real-time data and feeds it to LLaMA 3.2 3B as context
- LLaMA 3.2 3B provides a natural response incorporating the financial data
- For non-financial queries, it passes them directly to LLaMA 3.2 3B without modification
This approach seamlessly enhances LLaMA's capabilities with real-time financial data while preserving all of its original functionality.
Advanced Usage
Direct API Functions
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})
Troubleshooting
- "Error connecting to Ollama": Make sure Ollama is installed and running
- Company not found: Try using the official ticker symbol instead of the company name
- LLaMA 3.2 3B model not found: Run
ollama pull llama3.2:3b
to download the model
Acknowledgements
This project uses the yfinance library for retrieving Yahoo Finance data and Ollama for running LLaMA 3.2 3B locally.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.