by Adity-star
Provides real-time stock data, watchlist management, technical summaries, and a full‑featured dashboard through a FastAPI MCP server backed by the YFinance API.
Mcp Yfinance Stock Server enables AI agents, CLI tools, or custom applications to query live stock prices, maintain personal watchlists, and run technical analyses such as RSI, MACD, moving averages, volatility and trend detection. All functionality is exposed as MCP tools that can be called programmatically.
curl -LsSf https://astral.sh/uv/install.sh | sh
mkdir mcp-yfinance-server && cd mcp-yfinance-server
uv init
uv venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
uv pip install -e .
uv run main.py
mcp dev source/yf_server.py
mcp.config.json
(replace the absolute path with your location):
{
"mcpServers": {
"yfinance-price-tracker": {
"command": "uv",
"args": ["--directory", "/ABSOLUTE/PATH/TO/mcp-yfinance-server", "run", "main.py"]
}
}
}
get_stock_price
)add_to_watchlist
, get_watchlist_prices
)analyze_stock
, get_technical_summary
, get_trend_analysiss
)get_volatility_analysis
)compare_stocks
)Q: Do I need an API key for YFinance? A: No. YFinance scrapes publicly available Yahoo Finance data and works without authentication.
Q: Can I run the server on Windows?
A: Yes. Use the provided uv
commands; activate the virtual environment with .venv\Scripts\activate
.
Q: How many stocks can I add to the watchlist? A: The watchlist is stored in memory; it can handle dozens of tickers comfortably. For larger sets, persist the list externally.
Q: Is there a Docker image available?
A: The repository does not include a Dockerfile, but you can containerise it by installing uv
inside a Python base image and running uv run main.py
.
Q: How do I test the tools without a full client?
A: Run python run test_server_fun.py
to execute a quick sanity check of the exposed MCP functions.
This project sets up a stock Price server powered by the Yahoo Finance (YFinance) API and built for seamless integration with MCP (Model Control Protocol).
It allows AI agents or clients to:
Before diving into the full-blown stock server, I recommend starting with this simple crypto tracker built with Python + MCP 👇
🔗 GitHub Repo: https://github.com/Adity-star/mcp-crypto-server
You'll learn how to:
- Use MCP to expose crypto tools like get_price("BTC")
- Build an API with FastAPI
- Fetch real-time prices using the Alpaca API
Once you're familiar with the flow, move on to this more advanced stock tracker 💹
🔗 GitHub Repo: https://github.com/Adity-star/mcp-yfinance-server
📝 Detailed Blog: 👉 How I Built My Own Stock Server with Python, yFinance, and a Touch of Nerdy Ambition
Includes:
- Watchlists
- Real-time(ish) price updates
- Technical summaries
- A full-featured dashboard
- Trend + momentum indicators
- Watchlist management
We use uv — a modern, ultra-fast Python package manager — to manage our project environment.
Run the following commands in your terminal:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create and navigate to your project directory
mkdir mcp-yfinance-server
cd mcp-yfinance-server
# Initialize a new project
uv init
# Create and activate the virtual environment
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
Once your pyproject.toml is set up with dependencies, run:
# Run
uv pip install -e .
Once your environment is ready, start the stock server:
uv run main.py
🧪 Want a quick test first? Try checking the tools first:
python run test_server_fun.py
📄 Curious how the full server works?
Explore the source code here:
The server exposes many tools for AI agents and CLI users.
Here are some important tools, check out the complete tools list here:
Tool Name | Description |
---|---|
add_to_watchlist |
Add a stock ticker to your personal watchlist. |
analyze_stock |
Perform a 1-month technical trend analysis (RSI, MACD, MAs).. |
get_technical_summary |
Generate a comprehensive technical summary including indicators & signals.. |
get_watchlist_prices |
Fetch the most recent prices for all watchlisted tickers. |
get_trend_analysiss |
Analyze recent trend shifts, patterns, and divergences.. |
get_stock_price |
Retrieve the current price for a given ticker symbol. |
get_volatility_analysis |
Calculate historical volatility and ATR metrics.. |
compare_stocks |
Compare two stock prices (useful for relative performance analysis). |
✅ Total: 18 powerful tools to analyze and monitor stocks with precision.
These tools are ideal for:
⚙️ Keep this reference handy for building intelligent financial applications with the MCP server.
Easily explore and test your MCP tools using the MCP Server Inspector. Run the following command in your terminal:
$ mcp dev source/yf_server.py
This launches an interactive UI to:
To integrate your YFinance MCP server, add the following entry to your mcp.config.json file:
{
"mcpServers": {
"yfinance-price-tracker": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/YOUR/mcp-yfinance-server",
"run",
"main.py"
]
}
}
}
⚠️ Replace /ABSOLUTE/PATH/TO/... with actual file paths. 💡 Tip: Rename your server from crypto-price-tracker to yfinance-price-tracker for clarity.
Restart Claude Desktop (or any interface that uses MCP) to reload and activate your new YFinance tools.
This ensures the updated MCP configuration is recognized and all stock tracking tools are ready to use.
Use these example queries to test your MCP YFinance Server in action:
"Compare the stock prices of Tesla and Apple." → 🔧 Uses
compare_stocks
"Get the historical data for Tesla over the past month." → 📊 Uses
get_stock_history
"Add Apple, Tesla, and Reliance to my watchlist." → 📋 Uses
add_to_watchlist
"Show me a chart of Apple’s stock over the last 30 days." → 🖼️ Claude can fetch + visualize data using your server
📷 Sample Chart: 🖼 view Screenshot
🌐 Live Claude Site: Open Demo on Claude.site
🧪 These tests ensure your MCP integration is working end-to-end—from data retrieval to real-time analysis and visualization.
Feature | Outcome |
---|---|
✅ Stock Analysis | Analyse stock giving price, OHLC, returns, volume, insights and data. |
📈 Technical Analysis | Access indicators like RSI, MACD, MA, and a complete technical summary. |
📉 Volatility Reports | Analyze stock risk with ATR and volatility metrics. |
🔍 Trend Analysis | Detect trend shifts and divergence using price movement analysis. |
🧠 Visualisations | 18+ tools ready to power AI agents or dashboards to visualise stock. |
📋 Technical Charts | Analyse and monitor technical indicators for stocks in real-time. |
🖼️ Visual Insights | Generate charts and visual summaries with Claude Desktop. |
🎉 Ready to build your stock-tracking bot or intelligent financial dashboard? This project has all the core pieces.
Contributions are welcome! Whether you're fixing bugs, adding features, or improving documentation, your help makes this project better.
If you encounter bugs or have suggestions, please open an issue in the Issues section. Be sure to include:
Have a fix or improvement? Head over to the Pull Requests section and submit your PR. We’ll review and merge it ASAP!
If this project saved you from API rate limits or overpriced SaaS tools...
🚀 Let’s build better tools together.
If you’d like a tweet thread, carousel, or launch post for this — I’ve got your back 😎
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by goat-sdk
Enables AI agents to send and receive payments, purchase goods and services, execute investment strategies, tokenize assets, and obtain financial insights by leveraging blockchains, stablecoins, and wallets.
by financial-datasets
Provides access to income statements, balance sheets, cash flow statements, stock prices, market news, and cryptocurrency data through MCP tools for AI assistants.
by alpacahq
Enables large language models to trade stocks and options, retrieve real‑time and historical market data, and manage portfolios using plain English commands through a local or remote MCP server.
by XeroAPI
Provides a bridge between the Model Context Protocol and Xero's API, enabling standardized access to Xero accounting and business features.
by stefanoamorelli
Provides an MCP server that connects AI models to SEC EDGAR filings, enabling real‑time retrieval of company filings, financial statements, and insider‑trading data with exact XBRL precision and verifiable filing references.
by ariadng
Enables AI LLMs to execute trades on the MetaTrader 5 platform through the Model Context Protocol.
by calvernaz
Provides access to Alpha Vantage stock market data via an MCP server, supporting stdio and HTTP streaming modes with optional OAuth 2.1 authentication.
by kukapay
Integrates the Freqtrade cryptocurrency trading bot with MCP, exposing its REST API as tools for AI agents to perform automated trading operations.
by kukapay
Provides a comprehensive set of cryptocurrency technical analysis indicators and ready‑to‑use trading strategies through an MCP interface, enabling AI agents and applications to generate buy, hold, or sell signals.