Yahoo Finance MCP server

Integrates with Yahoo Finance to provide real-time stock quotes, financial statements, historical price data, and dividend tracking with advanced calculations for investment research and portfolio analysis.
Back to servers
Setup instructions
Provider
leogue
Release date
Aug 22, 2025
Stats
2 stars

StockMCP is a comprehensive Model Context Protocol (MCP) server that provides real-time stock market data using Yahoo Finance. It offers a JSON-RPC 2.0 compliant interface perfect for AI applications, financial analysis tools, and trading bots, giving you access to quotes, fundamentals, historical data, and analyst forecasts.

Free Hosted Endpoint

You can use StockMCP immediately without any setup via the free hosted endpoint:

Claude Desktop Configuration

For immediate access, add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "stock-mcp": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://stockmcp.leoguerin.fr/mcp",
        "--header",
        "--allow-http"
      ]
    }
  }
}

Configuration file locations:

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

Available Tools

  • get_realtime_quote: Retrieve current market data including price, volume, market cap, and key financial ratios
  • get_fundamentals: Access comprehensive financial statements and calculated ratios
  • get_price_history: Get historical OHLCV data with optional total return calculation
  • get_dividends_and_actions: Analyze dividend payment history and corporate actions
  • get_analyst_forecasts: Get analyst price targets, consensus ratings, and EPS forecasts
  • get_growth_projections: Forward growth projections for revenue, earnings, and free cash flow

Installation

API Key Setup

  • Get a free Alpha Vantage API key: Visit Alpha Vantage
  • Configure environment:
# Copy the example environment file
cp .env.example .env

# Edit .env and add your API key
ALPHAVANTAGE_KEY=your-actual-api-key-here

Using Docker (Recommended)

# Clone the repository
git clone https://github.com/yourusername/StockMCP.git
cd StockMCP

# Configure your API key (see API Key Setup above)
cp .env.example .env
# Edit .env with your Alpha Vantage API key

# Build and run with Docker
docker build -t stockmcp .
docker run -p 3001:3001 --env-file .env stockmcp

Local Installation

# Install dependencies with uv (fastest)
uv sync

# Or with pip
pip install -e .

# Configure your API key (see API Key Setup above)
cp .env.example .env
# Edit .env with your Alpha Vantage API key

# Run the server
python src/main.py
# Server runs on http://localhost:3001/mcp

Client Integration

Once your server is running, integrate it with MCP clients:

Claude Desktop

Edit the configuration file:

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

Add this configuration:

{
  "mcpServers": {
    "stock-mcp": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:3001/mcp",
        "--header",
        "--allow-http"
      ]
    }
  }
}

Cursor

Add to your MCP configuration:

{
  "stock-mcp": {
    "command": "npx",
    "args": [
      "mcp-remote",
      "http://localhost:3001/mcp",
      "--header",
      "--allow-http"
    ]
  }
}

Other MCP Clients

For any MCP-compatible client, use:

Usage

StockMCP implements the Model Context Protocol (MCP) for seamless integration with AI applications. Once running, the server provides:

  • Endpoint: http://localhost:3001/mcp
  • Protocol: JSON-RPC 2.0 over HTTP
  • Discovery: Use tools/list to get available tools
  • Execution: Use tools/call to execute tools with parameters

For detailed API examples and JSON schemas, access the interactive documentation at http://localhost:3001/mcp/docs when the server is running.

Docker Deployment

Build and Run

# Build the image
docker build -t stockmcp .

# Run the container
docker run -p 3001:3001 stockmcp

# Run in background
docker run -d -p 3001:3001 --name stockmcp-server stockmcp

Environment Configuration

The container exposes the API on port 3001 by default. You can customize this:

# Custom port mapping
docker run -p 8080:3001 stockmcp

# With environment variables
docker run -p 3001:3001 -e LOG_LEVEL=DEBUG stockmcp

Configuration Options

Server Configuration

The server can be configured through environment variables:

  • LOG_LEVEL - Logging level (DEBUG, INFO, WARNING, ERROR)
  • HOST - Server host (default: 0.0.0.0)
  • PORT - Server port (default: 3001)

API Limits & Data Sources

Primary Data Source: Yahoo Finance (yfinance)

  • Free tier with reasonable rate limits
  • Real-time and historical data
  • No API key required for basic usage

Secondary Data Source: Alpha Vantage (optional)

  • Enhanced earnings estimates and forecasts
  • Requires free API key for extended features
  • Graceful fallback when unavailable

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 "stock-mcp" '{"command":"npx","args":["mcp-remote","https://stockmcp.leoguerin.fr/mcp","--header","--allow-http"]}'

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": {
        "stock-mcp": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://stockmcp.leoguerin.fr/mcp",
                "--header",
                "--allow-http"
            ]
        }
    }
}

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": {
        "stock-mcp": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://stockmcp.leoguerin.fr/mcp",
                "--header",
                "--allow-http"
            ]
        }
    }
}

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