Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

mcp-stockscreen

MCP.Pizza Chef: twolven

The mcp-stockscreen is a specialized MCP server that integrates with Yahoo Finance to provide robust stock screening capabilities for LLMs like Claude Desktop. It supports comprehensive filtering based on technical indicators such as moving averages, RSI, ATR, and trend analysis; fundamental metrics including market cap, P/E ratio, dividend yield, and revenue growth; and options data like implied volatility, options volume, and put/call ratios. Additionally, it offers watchlist creation, management, and storage of screening results, enabling dynamic and data-driven stock analysis workflows. This server empowers AI models to perform nuanced stock market analysis and portfolio management tasks in real time.

Use This MCP server To

Screen stocks using technical analysis filters Filter stocks by fundamental financial metrics Analyze options data for trading signals Create and manage personalized stock watchlists Store and retrieve stock screening results Integrate stock screening into AI trading assistants Perform trend and volatility analysis on stocks Evaluate dividend yields and revenue growth Monitor earnings dates for options trading Calculate moving average distances for signals

README

StockScreen MCP Server

A Model Context Protocol (MCP) server providing comprehensive stock screening capabilities through Yahoo Finance. Enables LLMs to screen stocks based on technical, fundamental, and options criteria, with support for watchlist management and result storage.

Features

Stock Screening

  • Technical Analysis Screening

    • Price and volume filters
    • Moving averages (20, 50, 200 SMA)
    • RSI indicators
    • Average True Range (ATR)
    • Trend analysis (1d, 5d, 20d changes)
    • MA distance calculations
  • Fundamental Screening

    • Market capitalization filters
    • P/E ratio analysis
    • Dividend yield criteria
    • Revenue growth metrics
    • ETF-specific metrics (AUM, expense ratio)
  • Options Screening

    • Implied Volatility (IV) filters
    • Options volume and open interest
    • Put/Call ratio analysis
    • Bid-ask spread evaluation
    • Earnings date proximity checks

Data Management

  • Watchlist Creation and Management
  • Screening Result Storage
  • Default Symbol Categories
    • Mega Cap (>$200B)
    • Large Cap ($10B-$200B)
    • Mid Cap ($2B-$10B)
    • Small Cap ($300M-$2B)
    • Micro Cap (<$300M)
    • ETFs

Installation

# Install dependencies
pip install -r requirements.txt

# Clone the repository
git clone https://github.com/twolven/mcp-stockscreen.git
cd mcp-stockscreen

Usage

  1. Add to your Claude configuration: In your claude-desktop-config.json, add the following to the mcpServers section:
{
    "mcpServers": {
        "stockscreen": {
            "command": "python",
            "args": ["path/to/stockscreen.py"]
        }
    }
}

Replace "path/to/stockscreen.py" with the full path to where you saved the stockscreen.py file.

Available Tools

Available Tools

  1. run_stock_screen

Technical Screen Criteria

{
    "screen_type": "technical",
    "criteria": {
        "min_price": float,              # Minimum stock price
        "max_price": float,              # Maximum stock price
        "min_volume": int,               # Minimum average volume
        "above_sma_200": bool,           # Price above 200-day SMA
        "above_sma_50": bool,            # Price above 50-day SMA
        "min_rsi": float,                # Minimum RSI value
        "max_rsi": float,                # Maximum RSI value
        "max_atr_pct": float,            # Maximum ATR as percentage of price
        "category": str                  # Optional: market cap category filter
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

Fundamental Screen Criteria

{
    "screen_type": "fundamental",
    "criteria": {
        "min_market_cap": float,         # Minimum market capitalization
        "min_pe": float,                 # Minimum P/E ratio
        "max_pe": float,                 # Maximum P/E ratio
        "min_dividend": float,           # Minimum dividend yield (%)
        "min_revenue_growth": float,     # Minimum revenue growth rate
        "category": str,                 # Optional: market cap category filter
        
        # ETF-specific criteria
        "min_aum": float,                # Minimum assets under management
        "max_expense_ratio": float,      # Maximum expense ratio
        "min_volume": float              # Minimum trading volume
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

Options Screen Criteria

{
    "screen_type": "options",
    "criteria": {
        "min_iv": float,                 # Minimum implied volatility (%)
        "max_iv": float,                 # Maximum implied volatility (%)
        "min_option_volume": int,        # Minimum options volume
        "min_put_call_ratio": float,     # Minimum put/call ratio
        "max_spread": float,             # Maximum bid-ask spread (%)
        "min_days_to_earnings": int,     # Minimum days until earnings
        "max_days_to_earnings": int,     # Maximum days until earnings
        "category": str                  # Optional: market cap category filter
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

News Screen Criteria

{
    "screen_type": "news",
    "criteria": {
        "keywords": List[str],           # Keywords to search for in news
        "exclude_keywords": List[str],    # Keywords to exclude from results
        "min_days": int,                 # Minimum days back to search
        "max_days": int,                 # Maximum days back to search
        "management_changes": bool,       # Filter for management changes
        "require_all_keywords": bool,     # Require all keywords to match
        "category": str                  # Optional: market cap category filter
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

Custom Screen Criteria

{
    "screen_type": "custom",
    "criteria": {
        "category": str,                 # Optional: market cap category filter
        "technical": {
            # Any technical criteria from above
        },
        "fundamental": {
            # Any fundamental criteria from above
        },
        "options": {
            # Any options criteria from above
        },
        "news": {
            # Any news criteria from above
        }
    },
    "watchlist": str,                    # Optional: name of watchlist to screen
    "save_result": str                   # Optional: name to save results
}

Category Values

Ava1ilable market cap categories for filtering:

  • "mega_cap": >$200B
  • "large_cap": $10B-$200B
  • "mid_cap": $2B-$10B
  • "small_cap": $300M-$2B
  • "micro_cap": <$300M
  • "etf": ETF instruments
  1. manage_watchlist
{
    "action": str,                       # Required: "create", "update", "delete", "get"
    "name": str,                         # Required: watchlist name (1-50 chars, alphanumeric with _ -)
    "symbols": List[str]                 # Required for create/update: list of stock symbols
}
  1. get_screening_result
{
    "name": str                          # Required: name of saved screening result
}

Response Formats

Technical Screen Response

{
    "screen_type": "technical",
    "criteria": dict,                    # Original criteria used
    "matches": int,                      # Number of matching stocks
    "results": [                         # List of matching stocks
        {
            "symbol": str,
            "price": float,
            "volume": float,
            "rsi": float,
            "sma_20": float,
            "sma_50": float,
            "sma_200": float,
            "atr": float,
            "atr_pct": float,
            "price_changes": {
                "1d": float,             # 1-day price change %
                "5d": float,             # 5-day price change %
                "20d": float             # 20-day price change %
            },
            "ma_distances": {
                "pct_from_20sma": float,
                "pct_from_50sma": float,
                "pct_from_200sma": float
            }
        }
    ],
    "rejected": [                        # List of stocks that didn't match
        {
            "symbol": str,
            "rejection_reasons": List[str]
        }
    ],
    "timestamp": str
}

Usage Prompt for Claude

"I've enabled the stockscreen tools which provide stock screening capabilities. You can use three main functions:

  1. Screen stocks with various criteria types:

    • Technical: Price, volume, RSI, moving averages, ATR
    • Fundamental: Market cap, P/E, dividends, growth
    • Options: IV, volume, earnings dates
    • Custom: Combine multiple criteria types
  2. Manage watchlists:

    • Create and update symbol lists
    • Delete existing watchlists
    • Retrieve watchlist contents
  3. Access saved screening results:

    • Load previous screen results
    • Review matched symbols and criteria

All functions include error handling, detailed market data, and comprehensive responses."

Requirements

  • Python 3.12+
  • MCP Server
  • yfinance
  • pandas
  • numpy
  • asyncio

Limitations

  • Data sourced from Yahoo Finance with potential delays
  • Rate limits based on Yahoo Finance API restrictions
  • Options data availability depends on market hours
  • Some financial metrics may be delayed or unavailable

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Todd Wolven - (https://github.com/twolven)

Acknowledgments

  • Built with the Model Context Protocol (MCP) by Anthropic
  • Data provided by Yahoo Finance
  • Developed for use with Anthropic's Claude

mcp-stockscreen FAQ

How does mcp-stockscreen fetch stock data?
It uses Yahoo Finance as the primary data source to provide real-time and historical stock, fundamental, and options data.
Can I customize screening criteria with mcp-stockscreen?
Yes, it supports a wide range of customizable filters including technical indicators, fundamental metrics, and options parameters.
Does mcp-stockscreen support watchlist management?
Yes, users can create, update, and manage watchlists directly through the MCP server interface.
How are screening results stored and accessed?
Screening results are stored within the server, allowing retrieval and further analysis by LLMs or client applications.
Is mcp-stockscreen compatible with multiple LLM providers?
Yes, it is designed to work with various LLMs including Claude, OpenAI's GPT models, and Anthropic's Claude, ensuring broad compatibility.
What types of stock analysis does mcp-stockscreen support?
It supports technical analysis, fundamental analysis, and options screening to cover diverse trading strategies.
Can mcp-stockscreen handle ETF-specific metrics?
Yes, it includes filters for ETF assets under management (AUM) and expense ratios.
How does mcp-stockscreen assist with options trading?
It provides filters for implied volatility, options volume, open interest, put/call ratios, and earnings date proximity to inform options strategies.
Is real-time data supported by mcp-stockscreen?
While it relies on Yahoo Finance, it provides near real-time data suitable for most screening needs.
How do I integrate mcp-stockscreen with my AI workflow?
The server exposes structured APIs via MCP, allowing seamless integration with AI models and applications for automated stock analysis.