Yahoo Finance MCP for LLaMA 3.2 3B
local-only server
The server can only run on the client’s local machine because it depends on local resources.
Integrations
Used as an example for retrieving current stock prices through the Yahoo Finance API
Mentioned as an example company for retrieving sector information through Yahoo Finance API
Enables running LLaMA 3.2 3B locally, allowing the MCP to integrate Yahoo Finance data with LLaMA's capabilities
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:Copy
- Clone this repository:Copy
- Install the required Python dependencies:Copy
Usage
Running the MCP with Ollama Integration
To use the Yahoo Finance MCP with LLaMA 3.2 3B through Ollama:
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:
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:
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.
This server cannot be installed
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.