Stockscreen (Yahoo Finance) MCP server

Integrates with Yahoo Finance to provide advanced stock screening and analysis capabilities for technical, fundamental, and options-based trading strategies.
Back to servers
Setup instructions
Provider
Todd Wolven
Release date
Dec 20, 2024
Language
Python
Stats
28 stars

The StockScreen MCP server provides comprehensive stock screening capabilities through Yahoo Finance, enabling large language models to evaluate stocks based on technical, fundamental, and options criteria. It also supports watchlist management and result storage features for more organized analysis.

Installation

To install the StockScreen MCP server:

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

# Install dependencies
pip install -r requirements.txt

Configuration

Add the StockScreen MCP server to your Claude configuration by editing your claude-desktop-config.json file:

{
    "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.

Using the Stock Screening Tools

The StockScreen MCP server offers three main tools:

1. Run Stock Screen (run_stock_screen)

This tool allows you to screen stocks based on different criteria types.

Technical Screening

{
    "screen_type": "technical",
    "criteria": {
        "min_price": 50.0,              # Minimum stock price
        "max_price": 200.0,             # Maximum stock price
        "min_volume": 1000000,          # Minimum average volume
        "above_sma_200": true,          # Price above 200-day SMA
        "above_sma_50": true,           # Price above 50-day SMA
        "min_rsi": 40.0,                # Minimum RSI value
        "max_rsi": 70.0,                # Maximum RSI value
        "max_atr_pct": 5.0,             # Maximum ATR as percentage of price
        "category": "large_cap"         # Optional: market cap category filter
    },
    "watchlist": "my_watchlist",        # Optional: name of watchlist to screen
    "save_result": "tech_screen_result" # Optional: name to save results
}

Fundamental Screening

{
    "screen_type": "fundamental",
    "criteria": {
        "min_market_cap": 5000000000,   # Minimum market cap ($5B)
        "min_pe": 10.0,                 # Minimum P/E ratio
        "max_pe": 30.0,                 # Maximum P/E ratio
        "min_dividend": 2.0,            # Minimum dividend yield (%)
        "min_revenue_growth": 5.0,      # Minimum revenue growth rate
        "category": "large_cap"         # Optional: market cap category filter
    },
    "watchlist": "dividend_stocks",     # Optional: name of watchlist to screen
    "save_result": "div_screen_result"  # Optional: name to save results
}

Options Screening

{
    "screen_type": "options",
    "criteria": {
        "min_iv": 30.0,                 # Minimum implied volatility (%)
        "max_iv": 80.0,                 # Maximum implied volatility (%)
        "min_option_volume": 1000,      # Minimum options volume
        "min_put_call_ratio": 0.7,      # Minimum put/call ratio
        "max_spread": 5.0,              # Maximum bid-ask spread (%)
        "min_days_to_earnings": 5,      # Minimum days until earnings
        "max_days_to_earnings": 30,     # Maximum days until earnings
        "category": "mid_cap"           # Optional: market cap category filter
    },
    "save_result": "earnings_options"   # Optional: name to save results
}

News Screening

{
    "screen_type": "news",
    "criteria": {
        "keywords": ["acquisition", "partnership"],  # Keywords to search for
        "exclude_keywords": ["lawsuit", "downgrade"], # Keywords to exclude
        "min_days": 0,                  # Minimum days back to search
        "max_days": 7,                  # Maximum days back to search
        "management_changes": true,     # Filter for management changes
        "require_all_keywords": false,  # Require all keywords to match
        "category": "mid_cap"           # Optional: market cap category filter
    },
    "save_result": "recent_news"        # Optional: name to save results
}

Custom Screening (Combining Multiple Criteria Types)

{
    "screen_type": "custom",
    "criteria": {
        "category": "large_cap",
        "technical": {
            "min_price": 50.0,
            "above_sma_200": true
        },
        "fundamental": {
            "min_dividend": 1.5,
            "max_pe": 25.0
        },
        "options": {
            "min_days_to_earnings": 10
        }
    },
    "save_result": "custom_screen"
}

2. Manage Watchlists (manage_watchlist)

Create, update, delete, or retrieve watchlists:

# Create a new watchlist
{
    "action": "create",
    "name": "tech_stocks",
    "symbols": ["AAPL", "MSFT", "GOOGL", "AMZN", "META"]
}

# Update an existing watchlist
{
    "action": "update",
    "name": "tech_stocks",
    "symbols": ["AAPL", "MSFT", "GOOGL", "AMZN", "META", "NVDA"]
}

# Delete a watchlist
{
    "action": "delete",
    "name": "tech_stocks"
}

# Get watchlist contents
{
    "action": "get",
    "name": "tech_stocks"
}

3. Retrieve Saved Screening Results (get_screening_result)

Access previously saved screening results:

{
    "name": "tech_screen_result"
}

Market Cap Categories

You can filter stocks by market capitalization categories:

  • "mega_cap": >$200B
  • "large_cap": $10B-$200B
  • "mid_cap": $2B-$10B
  • "small_cap": $300M-$2B
  • "micro_cap": <$300M
  • "etf": ETF instruments

Example Screening Results

When you run a screen, you'll receive a structured response containing:

  • Original criteria used
  • Number of matching stocks
  • Detailed information for each matching stock
  • List of rejected stocks with reasons
  • Timestamp

For technical screens, each matching stock includes:

  • Symbol, price, volume
  • Technical indicators (RSI, SMAs, ATR)
  • Price changes (1-day, 5-day, 20-day)
  • Moving average distances

Suggested Claude Prompt

When working with Claude and the StockScreen tools, you can use the following prompt:

"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"

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "stockscreen" '{"command":"python","args":["path/to/stockscreen.py"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "stockscreen": {
            "command": "python",
            "args": [
                "path/to/stockscreen.py"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "stockscreen": {
            "command": "python",
            "args": [
                "path/to/stockscreen.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later