Sponsored by Deepsite.site

💹 MCP YFinance Stock Server

Created By
Adity-star8 months ago
Real-time stock API with Python, MCP server example, yfinance stock analysis dashboard
Content

💹 MCP YFinance Stock Server

Python MCP License

This project sets up a stock Price server powered by the Yahoo Finance (YFinance) API and built for seamless integration with MCP (Multi-Agent Control Protocol).

It allows AI agents or clients to:

  • Retrieve real-time stock data
  • Manage a watchlist
  • Perform full stock analysis
  • Run full technical indicators
  • And much more

image


🪙 Start Simple: Build a Crypto Price Tracker First

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

📈 Then Level Up: Build the yFinance Stock Server

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

📦 Step 1: Set Up the Environment (with uv)

We use uv — a modern, ultra-fast Python package manager — to manage our project environment.

🛠️ Installation & Setup

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

📥 Install the project

Once your pyproject.toml is set up with dependencies, run:

#  Run 
uv install .

🚀 Step 2: Running the MCP Server

Once your environment is ready, start the stock server:

cp ../yf_serve.py .
uv run source/yf_server.py

🧪 Want a quick test first? Try running the lightweight demo server:

uv run demo_stock_price_server.py

📄 Curious how the full server works?

Explore the source code here:

🔗 yf_server.py › GitHub


🛠️ MCP Tool Reference

The server exposes many tools for AI agents and CLI users.
Here are some important tools, check out the complete tools list here:

📦 Tool List

Tool NameDescription
add_to_watchlistAdd a stock ticker to your personal watchlist.
analyze_stockPerform a 1-month technical trend analysis (RSI, MACD, MAs)..
get_technical_summaryGenerate a comprehensive technical summary including indicators & signals..
get_watchlist_pricesFetch the most recent prices for all watchlisted tickers.
get_trend_analysissAnalyze recent trend shifts, patterns, and divergences..
get_stock_priceRetrieve the current price for a given ticker symbol.
get_volatility_analysisCalculate historical volatility and ATR metrics..
compare_stocksCompare two stock prices (useful for relative performance analysis).

Total: 18 powerful tools to analyze and monitor stocks with precision.

🧠 Use Cases

These tools are ideal for:

  • 📊 Dynamic watchlist management
  • 🔁 Trend and momentum detection
  • 📈 Deep-dive technical analysis for investment decisions
  • ⚠️ Volatility-based risk assessment
  • 🤖 Powering stock-focused autonomous agents or dashboards

⚙️ Keep this reference handy for building intelligent financial applications with the MCP server.


🔍 Step 3: Inspecting 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:

  • 🧰 View all available tools and resources
  • 📥 Test input/output for each tool
  • 📡 Monitor real-time responses from your server

image


⚙️ Step 4: Configure Your MCP Server

To integrate your YFinance MCP server, add the following entry to your mcp.config.json file:

{
  "mcpServers": {
    "yfinance-price-tracker": {
      "command": "/ABSOLUTE/PATH/TO/uv",
      "args": [
        "--directory",
        "/ABSOLUTE/PATH/TO/YOUR/mcp-yfinance-server",
        "run",
        "yf_server.py"
      ]
    }
  }
}

⚠️ Replace /ABSOLUTE/PATH/TO/... with actual file paths. 💡 Tip: Rename your server from crypto-price-tracker to yfinance-price-tracker for clarity.


🔁 Step 5: Restart Claude Desktop

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.


✅ Step 6: Testing the MCP Server with Claude Desktop

  • With everything installed and configured, you're ready to test your MCP server in Claude Desktop.

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.


📊 Results

⚙️ Outcomes You Can Expect

FeatureOutcome
Stock AnalysisAnalyse stock giving price, OHLC, returns, volume, insights and data.
📈 Technical AnalysisAccess indicators like RSI, MACD, MA, and a complete technical summary.
📉 Volatility ReportsAnalyze stock risk with ATR and volatility metrics.
🔍 Trend AnalysisDetect trend shifts and divergence using price movement analysis.
🧠 Visualisations18+ tools ready to power AI agents or dashboards to visualise stock.
📋 Technical ChartsAnalyse and monitor technical indicators for stocks in real-time.
🖼️ Visual InsightsGenerate 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.


📫 Feedback & Contributions

Contributions are welcome! Whether you're fixing bugs, adding features, or improving documentation, your help makes this project better.

🐛 Reporting Issues

If you encounter bugs or have suggestions, please open an issue in the Issues section. Be sure to include:

  • ✅ Steps to reproduce (if applicable)
  • 🔍 Expected vs. actual behavior
  • 📷 Screenshots or error logs (if relevant)

📬 Submit a Pull Request

Have a fix or improvement? Head over to the Pull Requests section and submit your PR. We’ll review and merge it ASAP!


💬 Spread the Word

If this project saved you from API rate limits or overpriced SaaS tools...

  • 🌟 Star the repo
  • 🍴 Fork it and build your own crypto/stock tool
  • 📲 Tag me on X @AdityaAkuskar — I’d love to see what you build!
  • 🔗 Connect with me on LinkedIn

📜 License

MIT © 2025 Ak Aditya.


🚀 Let’s build better tools together.

If you’d like a tweet thread, carousel, or launch post for this — I’ve got your back 😎

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
WindsurfThe new purpose-built IDE to harness magic
Playwright McpPlaywright MCP server
Serper MCP ServerA Serper MCP Server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Tavily Mcp
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
DeepChatYour AI Partner on Desktop
ChatWiseThe second fastest AI chatbot™
Amap Maps高德地图官方 MCP Server
CursorThe AI Code Editor
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。