Skip to main content

A Yfinance Server project

Project description

MseeP.ai Security Assessment Badge

๐Ÿ’น 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 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.

๐Ÿง  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

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.


๐Ÿ“ซ 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 ๐Ÿ˜Ž

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mseep_mcp_yfinance_server-0.1.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mseep_mcp_yfinance_server-0.1.1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file mseep_mcp_yfinance_server-0.1.1.tar.gz.

File metadata

File hashes

Hashes for mseep_mcp_yfinance_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fb8a760553071f1fac4b53722a9a0a150d4756d35ed1e726b367aa4b25d092dc
MD5 7669c290dc7767ebf704a79902294119
BLAKE2b-256 8166166c78eac6048110552c845b97885cb60ec1403d660e75b5b8c00e2b439b

See more details on using hashes here.

File details

Details for the file mseep_mcp_yfinance_server-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mseep_mcp_yfinance_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aebb69550a83293f9edbac8a099cfa864c6d4db0f97ca9246e90383ef79d3cb5
MD5 9cfd28acc2db358d858ef30503eb044a
BLAKE2b-256 b5a97b96e87832e971cb8835bc90abd2909c79ff2954b7f937b341f3380a0dee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page